/*
 * Carshow user interface class.  Provides display for carshow appl. to user.
 *
 */

/*
 * CarShowUI.java
 *
 * Created on Apr 1, 2011, 11:55:45 AM
 */

package carshow;
import java.awt.*;
import java.io.BufferedWriter;
import javax.swing.JCheckBox;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
 import static java.util.concurrent.TimeUnit.*;
import javax.swing.BoxLayout;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 *
 * @author Wayne Motycka
 * @author Dennis O'Melia
 */
public class CarShowUI extends javax.swing.JFrame {
    private static final Logger logger = Logger.getLogger("carshow.CarShowUI");
    /* Set the hosting car club name that appears on the forms here */
    /* At some point it may be desirable to make this settable on the admin panel */
    /** Name of the club hosting the car show */
    public static final String HostingClubName ="REBELS AUTO CLUB";
    /** Name of the host offering the SQLiteQS server instance */
    private String defaultServer = "localhost";
    private String SQLServer = defaultServer;
    private SqlClientReader clientReader = null; // socket reading thread
    private boolean debug = false;
    private String myIpAddress = null;
    private boolean in_init = false;
    private boolean in_update = false;
    private boolean ThisEntrantPrinted = false;
    private boolean newScoreEntry = false;
    private boolean waitLit = false;
    private boolean rptPoll = false;
    private boolean focusSearch = false;
    private boolean awardsChanged = false;
    private boolean failedWait = false;
    /** IP socket used to connect the SQLiteQS server */
    public Socket clientSocket;
    private PrintWriter out = null; // socket write object (request sink)
    private SQLiteQS ourDB = null;  // local DB SQL psuedo-server
    private String[] activeClubs = null;
    private String[] activeClasses = null;
    private static String auditResult = null;
    private String currentJudgingEntrant = null;
    private String CurrentCarShowName = null;
    private String CarShowDate = null;
    private static int auditCode = -1;
    private static int waitsCount = 15;  // # of 300ms cycles to wait for Wait indicators
    private ActionListener rptActionListener; // report cycling action listener
    private javax.swing.Timer rTimer = null; // refresh timer judge scoring report
    private java.awt.Component actDefaultButton = null;
    private java.awt.Color oldPrintColor;
    private java.util.List<javax.swing.JTextField> JudgingFields;
    private java.util.HashMap<String, javax.swing.JComponent> EntrantFields;
    private java.util.List<javax.swing.JCheckBox> AwardsBoxes;
    private java.util.HashMap<String, String> SpecialAwards;
    // class table descriptor, really just defines the columns.  We
    // do this manually because we want to have a shortcut to the model
    // that we can manipulate later with column mods.  This can also be
    // done in-line, but I thought at one time I wanted further capability
    // to the table which I'm getting most of for free in the default handlers
    private javax.swing.table.DefaultTableModel ClassTableModel
        = new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Class", "Class Description", "Start Year", "End Year"
            }
        );
    /*private final ScheduledExecutorService Report_scheduler =
       Executors.newScheduledThreadPool(1);*/

    /** Creates new form CarShowUI */
    public CarShowUI() {
        java.util.logging.Handler fh = null;
        try {
            fh = new java.util.logging.FileHandler("CarShowUI%u.log");
        } catch (IOException ex) {
            logger.log(Level.SEVERE, 
                "failed to create file handler logger for CarShowUI", ex);
        } catch (SecurityException ex) {
            logger.log(Level.SEVERE, 
                "falied to create file handler logger for CarShowUI", ex);
        }
        logger.addHandler(fh);
        logger.setLevel(Level.FINE);
        ourDB = SQLiteQS.getSQLiteQS();
        if (ourDB != null) ourDB.run();
        try {
            Thread.sleep(2000); // allow DB thread to initialize here...
        } catch (InterruptedException ie) {
            logger.log(Level.INFO,"sleep in init interrupted...");
        }
        in_init = true;
        initDB("Audit");
        int waitcnt = 0;
        while(auditResult == null) {
            try {
                Thread.sleep(300);
            } catch (InterruptedException ie) {
            logger.log(Level.INFO,"sleep on carshow.db init interrupted...");
            }
            if(waitcnt++ > waitsCount) break;
        }
        if (auditResult != null) {
            logger.log(Level.INFO,"auditResult: "+auditResult);
            if(auditCode > 0) logger.log(Level.INFO,"auditResult: "+auditCode+
                " new tables...");
        }
        else logger.log(Level.INFO,"auditResult null returned!");
        setIpAddress();
        initComponents();
        getAdminData();
        this.setTitle("The __"+HostingClubName+"__ Car Show");
        in_init = false;
        setJudgeSheetList();    // init table used to examine JudgingSheet panel
        setEntrantFieldsList(); // init table used to eval Registration panel
        setAwardsButtonList();  // init table used to eval Awards button
        initRegistration();
        formatClassTable();   // format displayed classes admin table
        formatJudgingTable(); // format the displayed (refreshed) judging tbl
        formatAwardsTable();  // format the displayed show results/awards table
        setRegFocusTraversal(); // get the desired order of tabs on Reg panel
        oldPrintColor = RegPrint.getForeground();
        RegPrint.setVisible(false); // hide the print button
        EntrantDeleteButton.setEnabled(false);
        actDefaultButton = getRootPane().getDefaultButton();
        KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        manager.addKeyEventPostProcessor(new typedKeyListener());
    }

    /**
     * get data from the SQL server
     * @param act_form active form name (via getName())
     * @param dest component data will be put on (combo box, JPane, JTable)
     * @param request
     * @return
     */
    private boolean sqlGet(Component dest, String request) {
        //dest.setName(act_form); // name the JComponent for reader thread
        ((myJTabbedPane)tabbedPane).setActiveComponent(dest);
        if (clientSocket == null) connect();
        else {
            disconnect();
            connect();
        }
        //System.err.println("sqlGet: DEBUG, opening out to server printwriter");
        if (clientSocket.isClosed()) {
            logger.log(Level.SEVERE,"UI sqlGet: socket is closed!");
            clientSocketError(-2);
        }
        else if(debug) logger.log(Level.INFO,"UI sqlGet: socket is open...");
        if (clientSocket.isConnected())
            if(debug) logger.log(Level.INFO,"UI sqlGet: socket is connected");
        else { 
            if(debug) logger.log(Level.INFO,"UI sqlGet: socket is not connected, that's OK, it will be...");
        }

        if(out == null) {
            try {
                out = new PrintWriter(new BufferedWriter( new
                    OutputStreamWriter(clientSocket.getOutputStream())), true);
            } catch (IOException ioe) {
                logger.log(Level.SEVERE, "out buffer open failed to client socket", ioe.toString());
                clientSocketError(-2);
                return false;
            }
        }
        if(debug) logger.log(Level.INFO,"sqlGet: sending request: "+request);
        out.print(request+"\n");
        out.flush();
        return true;
    }
    
    /**
     * put a record into the SQL database associated the output with the
     * specified Component.
     * @param comp GUI component where the output belongs
     * @param request SQL request
     * @return 0 on success, negative on error
     */
    private int sqlPut(Component comp, String request) {
        if(taskStackStatus(false)) { taskStackStatus(true); }
        ((myJTabbedPane)tabbedPane).setActiveComponent(comp);
        return sqlPut(request);
    }
    
    
    /**
     * puts a record into the SQL database
     * @param request SQL string
     * @return success or failure 0, -1
     */
    private int sqlPut(String request) {
        if (clientSocket == null) connect();
        else {
            disconnect();
            connect();
        }
        //System.err.println("sqlPut: DEBUG, opening out to server printwriter");
        if (clientSocket.isClosed()) {
            if(debug) logger.log(Level.SEVERE,"UI sqlPut: socket is closed!");
            clientSocketError(-2);
            return -1;
        }
        else if(debug) logger.log(Level.INFO,"UI sqlPut: socket is open...");
        if (!clientSocket.isConnected()) {
            System.err.println("UI sqlPut: socket is NOT connected");
            clientSocketError(-1);
            return -2;
        } else {
            if(debug) logger.log(Level.INFO,"UI sqlPut: socket is connected");
        }

        if(out == null) {
            try {
                out = new PrintWriter(new BufferedWriter( new
                    OutputStreamWriter(clientSocket.getOutputStream())), true);
            } catch (IOException ioe) {
                logger.log(Level.SEVERE,
                "sqlPut: out buffer open failed to client socket", ioe.toString());
                clientSocketError(-2);
                return -1;
            }
        }
        if(debug) { logger.log(Level.INFO,"sqlPut: sending request: "+request); }
        out.print(request+"\n");
        out.flush();
        //if(!in_init) ((myJTabbedPane)tabbedPane).clearWait();
        return 0;
    }

    /**
     * method to send the Audit command during init to check & build a
     * DB on startup
     */
    private boolean initDB(String request) {
        if (clientSocket == null) connect();
        else {
            disconnect();
            connect();
        }
        if(out == null) {
            try {
                out = new PrintWriter(new BufferedWriter( new
                    OutputStreamWriter(clientSocket.getOutputStream())), true);
            } catch (IOException ioe) {
                logger.log(Level.SEVERE,
                "initDB: out buffer open failed to client socket", ioe.toString());
                return false;
            }
        }
        if(debug)  { logger.log(Level.INFO,"initDB: sending request: "+request); }
        out.print(request+"\n");
        out.flush();
        return true;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        RegStatusButtonGroup = new javax.swing.ButtonGroup();
        wrapperPanel = new javax.swing.JPanel();
        tabbedPane = new myJTabbedPane();
        RegistrationPanel = new javax.swing.JPanel();
        EntryNumLabel = new javax.swing.JLabel();
        FirstNameLabel = new javax.swing.JLabel();
        LastNameLabel = new javax.swing.JLabel();
        AddrLabel = new javax.swing.JLabel();
        CityLabel = new javax.swing.JLabel();
        StateLabel = new javax.swing.JLabel();
        ZipLabel = new javax.swing.JLabel();
        MakeLabel = new javax.swing.JLabel();
        ModelLabel = new javax.swing.JLabel();
        YearLabel = new javax.swing.JLabel();
        EntrantNumber = new javax.swing.JTextField();
        FirstName = new javax.swing.JTextField();
        LastName = new javax.swing.JTextField();
        EntrantAddress = new javax.swing.JTextField();
        EntrantState = new javax.swing.JTextField();
        EntrantZipCode = new javax.swing.JTextField();
        EntrantPhone = new javax.swing.JTextField();
        EntrantMake = new javax.swing.JTextField();
        EntrantModel = new javax.swing.JTextField();
        PhoneLabel = new javax.swing.JLabel();
        EntrantYear = new javax.swing.JTextField();
        AddEntrant = new javax.swing.JButton();
        ClassLabel = new javax.swing.JLabel();
        ColorLabel = new javax.swing.JLabel();
        EntrantColor = new javax.swing.JTextField();
        EntrantCity = new javax.swing.JTextField();
        ModelLabel1 = new javax.swing.JLabel();
        EntrantSearch = new javax.swing.JButton();
        EntrantClear = new javax.swing.JButton();
        HostClubName = new javax.swing.JLabel();
        ParkingNumLabel = new javax.swing.JLabel();
        EntrantParking = new javax.swing.JTextField();
        EntrantClub = new javax.swing.JComboBox();
        EntrantClass = new javax.swing.JComboBox();
        regWait = new java.awt.Label();
        RegPrint = new javax.swing.JButton();
        EntrantDeleteButton = new javax.swing.JButton();
        ClassSetPanel = new javax.swing.JPanel();
        ClassMnemonicLabel = new javax.swing.JLabel();
        ClassNameLabel = new javax.swing.JLabel();
        StartYearLabel = new javax.swing.JLabel();
        NewClassMnemonic = new javax.swing.JTextField();
        NewClassName = new javax.swing.JTextField();
        NewClassEndYear = new javax.swing.JTextField();
        EndYearLabel = new javax.swing.JLabel();
        AddClassButton = new javax.swing.JButton();
        NewClassStartYear = new javax.swing.JTextField();
        DeleteClassButton = new javax.swing.JButton();
        ClassWait = new java.awt.Label();
        ClassListPanel = new javax.swing.JScrollPane();
        ClassListTable = new javax.swing.JTable();
        JudgeSheetPanel = new javax.swing.JPanel();
        JudgeSheetSubPanel = new javax.swing.JPanel();
        EntryNumLabel2 = new javax.swing.JLabel();
        MakeLabel1 = new javax.swing.JLabel();
        ModelLabel2 = new javax.swing.JLabel();
        YearLabel1 = new javax.swing.JLabel();
        JS_EntrantNumber = new javax.swing.JTextField();
        JS_EntrantMake = new javax.swing.JTextField();
        JS_EntrantModel = new javax.swing.JTextField();
        JS_EntrantYear = new javax.swing.JTextField();
        ClassLabel1 = new javax.swing.JLabel();
        JS_EntrantClass = new javax.swing.JTextField();
        JSColorLabel = new javax.swing.JLabel();
        JS_EntrantColor = new javax.swing.JTextField();
        JS_ParkingNumLabel = new javax.swing.JLabel();
        JS_ParkingNumber = new javax.swing.JTextField();
        BodyScoreLabel1 = new javax.swing.JLabel();
        JS_BodyScore1 = new javax.swing.JTextField();
        EngineScoreLabel1 = new javax.swing.JLabel();
        JS_InteriorScore1 = new javax.swing.JTextField();
        InteriorScoreLabel1 = new javax.swing.JLabel();
        JS_EngineScore1 = new javax.swing.JTextField();
        ChassisScoreLabel1 = new javax.swing.JLabel();
        JS_ChassisScore1 = new javax.swing.JTextField();
        WheelsScoreLabel1 = new javax.swing.JLabel();
        JS_TireScore1 = new javax.swing.JTextField();
        TiresScoreLabel1 = new javax.swing.JLabel();
        JS_WheelsScore1 = new javax.swing.JTextField();
        BodyMxPtsLabel1 = new javax.swing.JLabel();
        EngineMxPtsLabel1 = new javax.swing.JLabel();
        InteriorMxPtsLabel1 = new javax.swing.JLabel();
        ChassisMxPtsLabel1 = new javax.swing.JLabel();
        TiresMxPtsLabel1 = new javax.swing.JLabel();
        WheelsMxPtsLabel1 = new javax.swing.JLabel();
        JudgeInitialsLabel1 = new javax.swing.JLabel();
        JS_JudgeInitials1 = new javax.swing.JTextField();
        BodyScoreLabel2 = new javax.swing.JLabel();
        JS_BodyScore2 = new javax.swing.JTextField();
        BodyMxPtsLabel2 = new javax.swing.JLabel();
        EngineScoreLabel2 = new javax.swing.JLabel();
        JS_EngineScore2 = new javax.swing.JTextField();
        EngineMxPtsLabel2 = new javax.swing.JLabel();
        InteriorScoreLabel2 = new javax.swing.JLabel();
        JS_InteriorScore2 = new javax.swing.JTextField();
        InteriorMxPtsLabel2 = new javax.swing.JLabel();
        ChassisScoreLabel2 = new javax.swing.JLabel();
        JS_ChassisScore2 = new javax.swing.JTextField();
        ChassisMxPtsLabel2 = new javax.swing.JLabel();
        TiresScoreLabel2 = new javax.swing.JLabel();
        JS_TireScore2 = new javax.swing.JTextField();
        TiresMxPtsLabel2 = new javax.swing.JLabel();
        WheelsScoreLabel2 = new javax.swing.JLabel();
        JS_WheelsScore2 = new javax.swing.JTextField();
        WheelsMxPtsLabel2 = new javax.swing.JLabel();
        JudgeIntialsLabel2 = new javax.swing.JLabel();
        JS_JudgeInitials2 = new javax.swing.JTextField();
        JS_SaveButton = new javax.swing.JButton();
        judgingSheetWait = new java.awt.Label();
        BestCustomBox = new javax.swing.JCheckBox();
        BestStreetRodBox = new javax.swing.JCheckBox();
        BestInteriorBox = new javax.swing.JCheckBox();
        BestPaintBox = new javax.swing.JCheckBox();
        RebelsChoiceBox = new javax.swing.JCheckBox();
        ParticipantChoiceBox = new javax.swing.JCheckBox();
        BestTruckBox = new javax.swing.JCheckBox();
        specialtyAwardsLabel = new javax.swing.JLabel();
        JudgingPanel = new javax.swing.JPanel();
        JudgingPane = new javax.swing.JScrollPane();
        CarScores = new javax.swing.JTable();
        JudgingWait = new java.awt.Label();
        AwardsPanel = new javax.swing.JPanel();
        AwardsPane = new javax.swing.JScrollPane();
        ReportTable = new javax.swing.JTable();
        AwardsPrintButton = new javax.swing.JButton();
        AwardsSaveResultsButton = new javax.swing.JButton();
        AwardsWait = new java.awt.Label();
        MostClubMembers = new javax.swing.JTextField();
        MostClubsLabel = new javax.swing.JLabel();
        SecondMostClub = new javax.swing.JTextField();
        AdminPanel = new javax.swing.JPanel();
        ContestNameLabel = new javax.swing.JLabel();
        ContestName = new javax.swing.JTextField();
        ShowDateLabel = new javax.swing.JLabel();
        ShowLocationLabel = new javax.swing.JLabel();
        ShowDate = new javax.swing.JTextField();
        ShowLocation = new javax.swing.JTextField();
        ServerNameLabel = new javax.swing.JLabel();
        ScoringServerName = new javax.swing.JTextField();
        AdminWait = new java.awt.Label();
        debugButton = new javax.swing.JToggleButton();
        jLabel1 = new javax.swing.JLabel();
        IPAddrLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        wrapperPanel.setName("wrapperPanel");

        tabbedPane.setName("tabbedPane"); // NOI18N
        tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tabbedPaneStateChanged(evt);
            }
        });

        RegistrationPanel.setName("RegistrationPanel"); // NOI18N
        RegistrationPanel.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                RegPanelFocusGained(evt);
            }
        });

        EntryNumLabel.setText("Registration Number");

        FirstNameLabel.setText("Name First");

        LastNameLabel.setText("Last");

        AddrLabel.setText("Address");

        CityLabel.setText("City");

        StateLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        StateLabel.setText("State");
        StateLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        ZipLabel.setText("Zip");

        MakeLabel.setText("Car Make");

        ModelLabel.setText("Car Model");

        YearLabel.setText("Year");

        EntrantNumber.setBackground(new java.awt.Color(255, 255, 153));
        EntrantNumber.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                EntNumMouseClicked(evt);
            }
        });
        EntrantNumber.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                EntrantNumberFocusLost(evt);
            }
        });

        EntrantState.setColumns(2);
        EntrantState.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        EntrantZipCode.setColumns(6);

        PhoneLabel.setText("Phone");

        AddEntrant.setText("Add Entrant");
        AddEntrant.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddEntrantActionPerformed(evt);
            }
        });

        ClassLabel.setText("Entry Class");

        ColorLabel.setText("Color");

        ModelLabel1.setText("Car Club");

        EntrantSearch.setText("Search Entrant");
        EntrantSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EntrantSearchActionPerformed(evt);
            }
        });

        EntrantClear.setText("Clear ");
        EntrantClear.setName("EntrantClear");
        EntrantClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EntrantClearActionPerformed(evt);
            }
        });

        HostClubName.setFont(new java.awt.Font("Copperplate Gothic Light", 1, 36)); // NOI18N
        HostClubName.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        HostClubName.setText(HostingClubName);

        ParkingNumLabel.setText("Parking Number");

        EntrantParking.setBackground(new java.awt.Color(153, 255, 153));
        EntrantParking.setFocusCycleRoot(true);

        EntrantClub.setEditable(true);
        EntrantClub.setName("EntrantClub"); // NOI18N

        EntrantClass.setMaximumRowCount(10);
        EntrantClass.setName("EntrantClass"); // NOI18N
        EntrantClass.setPreferredSize(new java.awt.Dimension(152, 20));

        regWait.setEnabled(false);
        regWait.setName("regWait"); // NOI18N
        regWait.setText("Wait...");

        RegPrint.setText("Print");
        RegPrint.setName("RegPrint");
        RegPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RegPrintActionPerformed(evt);
            }
        });

        EntrantDeleteButton.setText("Delete");
        EntrantDeleteButton.setName("EntrantDelete");
        EntrantDeleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EntrantDeleteActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout RegistrationPanelLayout = new org.jdesktop.layout.GroupLayout(RegistrationPanel);
        RegistrationPanel.setLayout(RegistrationPanelLayout);
        RegistrationPanelLayout.setHorizontalGroup(
            RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(RegistrationPanelLayout.createSequentialGroup()
                .add(64, 64, 64)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(PhoneLabel)
                    .add(AddrLabel)
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(YearLabel)
                        .add(52, 52, 52)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(EntrantYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(EntrantModel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 146, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(21, 21, 21)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(ColorLabel)
                            .add(MakeLabel))
                        .add(18, 18, 18)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(EntrantColor, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                            .add(EntrantMake)))
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(ModelLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(ClassLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .add(18, 18, 18)
                        .add(EntrantClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 310, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(ModelLabel1)
                        .add(18, 18, 18)
                        .add(EntrantClub, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 196, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(RegistrationPanelLayout.createSequentialGroup()
                            .add(CityLabel)
                            .add(284, 284, 284))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, RegistrationPanelLayout.createSequentialGroup()
                            .add(266, 266, 266)
                            .add(regWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
            .add(RegistrationPanelLayout.createSequentialGroup()
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(36, 36, 36)
                        .add(EntryNumLabel)
                        .add(4, 4, 4)
                        .add(EntrantNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(486, 486, 486)
                        .add(ParkingNumLabel)
                        .add(4, 4, 4)
                        .add(EntrantParking, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(64, 64, 64)
                        .add(FirstNameLabel)
                        .add(23, 23, 23)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(RegistrationPanelLayout.createSequentialGroup()
                                .add(EntrantCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 194, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(18, 18, 18)
                                .add(StateLabel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(EntrantState, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(18, 18, 18)
                                .add(ZipLabel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(EntrantZipCode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, RegistrationPanelLayout.createSequentialGroup()
                                    .add(FirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 125, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(27, 27, 27)
                                    .add(LastNameLabel)
                                    .add(10, 10, 10)
                                    .add(LastName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 146, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(EntrantAddress))
                            .add(EntrantPhone, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(138, 138, 138)
                        .add(AddEntrant, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(127, 127, 127)
                        .add(EntrantSearch)
                        .add(121, 121, 121)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(EntrantDeleteButton)
                            .add(EntrantClear))
                        .add(44, 44, 44)
                        .add(RegPrint))
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(HostClubName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 886, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(0, 0, Short.MAX_VALUE))
        );
        RegistrationPanelLayout.setVerticalGroup(
            RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(RegistrationPanelLayout.createSequentialGroup()
                .add(30, 30, 30)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(EntrantNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(EntrantParking, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(3, 3, 3)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(EntryNumLabel)
                            .add(ParkingNumLabel))))
                .add(18, 18, 18)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(FirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(LastName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(3, 3, 3)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(FirstNameLabel)
                            .add(LastNameLabel))))
                .add(6, 6, 6)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(EntrantAddress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(AddrLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(EntrantState)
                        .add(ZipLabel)
                        .add(EntrantZipCode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(StateLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, RegistrationPanelLayout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, EntrantCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, CityLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistrationPanelLayout.createSequentialGroup()
                        .add(7, 7, 7)
                        .add(EntrantPhone, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, RegistrationPanelLayout.createSequentialGroup()
                        .add(8, 8, 8)
                        .add(PhoneLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(18, 18, 18)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(EntrantMake, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(MakeLabel))
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(EntrantYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(YearLabel)))
                .add(18, 18, 18)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(EntrantModel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(ModelLabel)
                        .add(ColorLabel))
                    .add(EntrantColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(15, 15, 15)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(EntrantClass, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(ClassLabel)
                        .add(EntrantClub)
                        .add(ModelLabel1)))
                .add(18, 18, 18)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(regWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(EntrantDeleteButton))
                .add(20, 20, 20)
                .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(EntrantSearch)
                    .add(RegistrationPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(EntrantClear)
                        .add(RegPrint))
                    .add(AddEntrant))
                .add(18, 18, 18)
                .add(HostClubName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(134, 134, 134))
        );

        HostClubName.getAccessibleContext().setAccessibleName("");
        ((myJTabbedPane)tabbedPane).addMarker(regWait);
        regWait.setVisible(false);
        RegPrint.setVisible(false);

        tabbedPane.addTab("Registration", RegistrationPanel);

        ClassSetPanel.setName("ClassPane"); // NOI18N
        ClassSetPanel.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                ClassSetPanelFocusGained(evt);
            }
        });

        ClassMnemonicLabel.setText("Class");

        ClassNameLabel.setText("Class Name");

        StartYearLabel.setText("Start Year");

        NewClassMnemonic.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                NewClassFocusLost(evt);
            }
        });

        EndYearLabel.setText("End Year");

        AddClassButton.setText("Add Class");
        AddClassButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddClassButtonActionPerformed(evt);
            }
        });

        DeleteClassButton.setText("Delete Class");
        DeleteClassButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteClassButtonActionPerformed(evt);
            }
        });

        ClassWait.setEnabled(false);
        ClassWait.setName("ClassWait"); // NOI18N
        ClassWait.setText("Wait...");

        ClassListPanel.setPreferredSize(new java.awt.Dimension(454, 508));

        ClassListTable.setModel(ClassTableModel);
        ClassListTable.setMinimumSize(new java.awt.Dimension(60, 240));
        ClassListTable.setName("ClassListTable"); // NOI18N
        ClassListPanel.setViewportView(ClassListTable);

        org.jdesktop.layout.GroupLayout ClassSetPanelLayout = new org.jdesktop.layout.GroupLayout(ClassSetPanel);
        ClassSetPanel.setLayout(ClassSetPanelLayout);
        ClassSetPanelLayout.setHorizontalGroup(
            ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(ClassSetPanelLayout.createSequentialGroup()
                .add(21, 21, 21)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(ClassSetPanelLayout.createSequentialGroup()
                        .add(ClassListPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 649, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .add(ClassSetPanelLayout.createSequentialGroup()
                        .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(ClassMnemonicLabel)
                            .add(ClassNameLabel)
                            .add(EndYearLabel)
                            .add(StartYearLabel))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(ClassSetPanelLayout.createSequentialGroup()
                                .add(AddClassButton)
                                .add(76, 76, 76)
                                .add(DeleteClassButton))
                            .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(NewClassMnemonic, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(NewClassName)
                                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, NewClassEndYear)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, NewClassStartYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                        .add(744, 744, 744))))
            .add(ClassSetPanelLayout.createSequentialGroup()
                .add(313, 313, 313)
                .add(ClassWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 0, Short.MAX_VALUE))
        );
        ClassSetPanelLayout.setVerticalGroup(
            ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(ClassSetPanelLayout.createSequentialGroup()
                .add(38, 38, 38)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ClassMnemonicLabel)
                    .add(NewClassMnemonic, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(NewClassName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(ClassNameLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(StartYearLabel)
                    .add(NewClassStartYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(EndYearLabel)
                    .add(NewClassEndYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(ClassSetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(AddClassButton)
                    .add(DeleteClassButton))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ClassListPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 275, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ClassWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(90, Short.MAX_VALUE))
        );

        ClassWait.getAccessibleContext().setAccessibleName("ClassWait");
        ((myJTabbedPane)tabbedPane).addMarker(ClassWait);
        ClassWait.setVisible(false);

        tabbedPane.addTab("Class Setup", ClassSetPanel);

        JudgeSheetPanel.setName("JudgeSheetPanel"); // NOI18N

        JudgeSheetSubPanel.setName("JudgeSubPanel"); // NOI18N

        EntryNumLabel2.setText("Registration Number");

        MakeLabel1.setText("Car Make");

        ModelLabel2.setText("Car Model");

        YearLabel1.setText("Year");

        JS_EntrantNumber.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                JS_RegNumFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                JudgeSheetEntNumberFocusLost(evt);
            }
        });

        ClassLabel1.setText("Entry Class");

        JSColorLabel.setText("Color");

        JS_ParkingNumLabel.setText("Parking Number");

        BodyScoreLabel1.setText("Body Score");

        JS_BodyScore1.setName("j1_cat1");

        EngineScoreLabel1.setText("Engine Score");

        JS_InteriorScore1.setName("j1_cat3");

        InteriorScoreLabel1.setText("Interior Score");

        JS_EngineScore1.setName("j1_cat2");

        ChassisScoreLabel1.setText("Chassis Score");

        JS_ChassisScore1.setName("j1_cat4");

        WheelsScoreLabel1.setText("Wheels Score");
        WheelsScoreLabel1.setRequestFocusEnabled(false);

        JS_TireScore1.setName("j1_cat5");

        TiresScoreLabel1.setText("Tires Score");

        JS_WheelsScore1.setName("j1_cat6");

        BodyMxPtsLabel1.setText("20 pts Max");

        EngineMxPtsLabel1.setText("20 pts Max");

        InteriorMxPtsLabel1.setText("20 pts Max");

        ChassisMxPtsLabel1.setText("20 pts Max");

        TiresMxPtsLabel1.setText("10 pts Max");

        WheelsMxPtsLabel1.setText("10 pts Max");

        JudgeInitialsLabel1.setText("Judge #1 Initials");

        BodyScoreLabel2.setText("Body Score");

        JS_BodyScore2.setName("j2_cat1");

        BodyMxPtsLabel2.setText("20 pts Max");

        EngineScoreLabel2.setText("Engine Score");

        JS_EngineScore2.setName("j2_cat2");

        EngineMxPtsLabel2.setText("20 pts Max");

        InteriorScoreLabel2.setText("Interior Score");

        JS_InteriorScore2.setName("j2_cat3");

        InteriorMxPtsLabel2.setText("20 pts Max");

        ChassisScoreLabel2.setText("Chassis Score");

        JS_ChassisScore2.setName("j2_cat4");

        ChassisMxPtsLabel2.setText("20 pts Max");

        TiresScoreLabel2.setText("Tires Score");

        JS_TireScore2.setName("j2_cat5");

        TiresMxPtsLabel2.setText("10 pts Max");

        WheelsScoreLabel2.setText("Wheels Score");

        JS_WheelsScore2.setName("j2_cat6");

        WheelsMxPtsLabel2.setText("10 pts Max");

        JudgeIntialsLabel2.setText("Judge #2 Initials");

        JS_JudgeInitials2.setName("j2_cat6");

        JS_SaveButton.setText("Save");
        JS_SaveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JudgeSheetSaveActionPerformed(evt);
            }
        });

        judgingSheetWait.setEnabled(false);
        judgingSheetWait.setName("judgingSheetWait"); // NOI18N
        judgingSheetWait.setText("Wait...");

        BestCustomBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        BestCustomBox.setText("Best Custom Car");
        BestCustomBox.setName("BestCustomBox");
        BestCustomBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        BestStreetRodBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        BestStreetRodBox.setText("Best Street Rod");
        BestStreetRodBox.setName("BestStreetRodBox");
        BestStreetRodBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        BestInteriorBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        BestInteriorBox.setText("Best Interior");
        BestInteriorBox.setName("BestInteriorBox");
        BestInteriorBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        BestPaintBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        BestPaintBox.setText("Best Paint");
        BestPaintBox.setName("BestPaintBox");
        BestPaintBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        RebelsChoiceBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        RebelsChoiceBox.setText("Rebels Club Choice");
        RebelsChoiceBox.setName("RebelsChoiceBox");
        RebelsChoiceBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        ParticipantChoiceBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        ParticipantChoiceBox.setText("Participants Choice");
        ParticipantChoiceBox.setName("ParticipantChoiceBox");
        ParticipantChoiceBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        BestTruckBox.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        BestTruckBox.setText("Best Truck");
        BestTruckBox.setName("BestTruckBox");
        BestTruckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSBoxesActionPerformed(evt);
            }
        });

        specialtyAwardsLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        specialtyAwardsLabel.setText("Specialty Awards");
        specialtyAwardsLabel.setFocusable(false);
        specialtyAwardsLabel.setName("specialtyAwardsLabel");
        specialtyAwardsLabel.setRequestFocusEnabled(false);
        specialtyAwardsLabel.setVerifyInputWhenFocusTarget(false);

        org.jdesktop.layout.GroupLayout JudgeSheetSubPanelLayout = new org.jdesktop.layout.GroupLayout(JudgeSheetSubPanel);
        JudgeSheetSubPanel.setLayout(JudgeSheetSubPanelLayout);
        JudgeSheetSubPanelLayout.setHorizontalGroup(
            JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(EntryNumLabel2)
                                    .add(JS_ParkingNumLabel)
                                    .add(ClassLabel1))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(JS_EntrantNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                                    .add(JS_ParkingNumber)
                                    .add(JS_EntrantClass))
                                .add(113, 113, 113)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(MakeLabel1)
                                    .add(JSColorLabel))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(JS_EntrantMake, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
                                    .add(JS_EntrantColor))
                                .add(62, 62, 62)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(ModelLabel2)
                                    .add(YearLabel1))
                                .add(18, 18, 18)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(JS_EntrantYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_EntrantModel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(33, 33, 33)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(BestCustomBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(BestStreetRodBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(BestTruckBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(BestInteriorBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JS_SaveButton)
                                        .add(42, 42, 42)))
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(BestPaintBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(RebelsChoiceBox)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(ParticipantChoiceBox))
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(10, 10, 10)
                                        .add(judgingSheetWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                        .add(0, 0, Short.MAX_VALUE))
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(36, 36, 36)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(specialtyAwardsLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(0, 0, Short.MAX_VALUE))
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(BodyMxPtsLabel1)
                                    .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                        .add(BodyScoreLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(BodyScoreLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(JS_BodyScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(JS_BodyScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 55, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(BodyMxPtsLabel2))
                                .add(18, 18, 18)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(EngineScoreLabel1)
                                    .add(EngineMxPtsLabel1)
                                    .add(EngineScoreLabel2)
                                    .add(EngineMxPtsLabel2)
                                    .add(JS_EngineScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_EngineScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(18, 18, 18)
                                        .add(InteriorMxPtsLabel2))
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(18, 18, 18)
                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                                .add(1, 1, 1)
                                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(InteriorScoreLabel1)
                                                    .add(InteriorScoreLabel2)
                                                    .add(JS_InteriorScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                            .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                                .add(InteriorMxPtsLabel1)
                                                .add(JS_InteriorScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                                .add(43, 43, 43)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(ChassisScoreLabel2)
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(ChassisScoreLabel1)
                                            .add(ChassisMxPtsLabel1)
                                            .add(JS_ChassisScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                            .add(JS_ChassisScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                                .add(33, 33, 33)
                                                .add(JS_TireScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                                .add(27, 27, 27)
                                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(TiresScoreLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                    .add(TiresMxPtsLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                                        .add(8, 8, 8)
                                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(TiresMxPtsLabel2)
                                                            .add(JS_TireScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                                    .add(TiresScoreLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                                    .add(ChassisMxPtsLabel2))
                                .add(28, 28, 28)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JS_WheelsScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(JudgeInitialsLabel1)
                                        .add(18, 18, 18)
                                        .add(JS_JudgeInitials1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(28, 28, 28))
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(WheelsMxPtsLabel1)
                                            .add(WheelsScoreLabel2))
                                        .add(0, 0, Short.MAX_VALUE))
                                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(WheelsScoreLabel1)
                                            .add(WheelsMxPtsLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                        .addContainerGap())
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, JudgeSheetSubPanelLayout.createSequentialGroup()
                                        .add(JS_WheelsScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(JudgeIntialsLabel2)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(JS_JudgeInitials2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(32, 32, 32))))))))
        );
        JudgeSheetSubPanelLayout.setVerticalGroup(
            JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(EntryNumLabel2)
                    .add(JS_EntrantNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(JS_EntrantMake, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(MakeLabel1)
                    .add(ModelLabel2)
                    .add(JS_EntrantModel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(JS_ParkingNumLabel)
                    .add(JSColorLabel)
                    .add(JS_EntrantColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(JS_ParkingNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(YearLabel1)
                    .add(JS_EntrantYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ClassLabel1)
                    .add(JS_EntrantClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(64, 64, 64)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(BodyScoreLabel1)
                                .add(7, 7, 7))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(TiresScoreLabel1)
                                    .add(WheelsScoreLabel1))
                                .add(6, 6, 6)))
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(JS_TireScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_WheelsScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_JudgeInitials1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JudgeInitialsLabel1))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(TiresMxPtsLabel1)
                                    .add(WheelsMxPtsLabel1)))
                            .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false)
                                    .add(JS_BodyScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_EngineScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(JS_InteriorScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(BodyMxPtsLabel1)
                                    .add(InteriorMxPtsLabel1)
                                    .add(EngineMxPtsLabel1)))))
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(EngineScoreLabel1)
                            .add(InteriorScoreLabel1)
                            .add(ChassisScoreLabel1))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(JS_ChassisScore1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ChassisMxPtsLabel1)))
                .add(94, 94, 94)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(BodyScoreLabel2)
                        .add(7, 7, 7)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(JS_BodyScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(JS_EngineScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(EngineScoreLabel2)
                            .add(InteriorScoreLabel2))
                        .add(7, 7, 7)
                        .add(JS_InteriorScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(InteriorMxPtsLabel2)
                            .add(ChassisMxPtsLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(EngineMxPtsLabel2)
                            .add(BodyMxPtsLabel2)))
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(22, 22, 22)
                        .add(JS_JudgeInitials2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(JudgeSheetSubPanelLayout.createSequentialGroup()
                        .add(1, 1, 1)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(ChassisScoreLabel2)
                            .add(WheelsScoreLabel2)
                            .add(TiresScoreLabel2))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(JS_TireScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(JS_WheelsScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(JudgeIntialsLabel2))
                            .add(JS_ChassisScore2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(TiresMxPtsLabel2)
                            .add(WheelsMxPtsLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(specialtyAwardsLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(BestCustomBox)
                    .add(BestStreetRodBox)
                    .add(BestTruckBox)
                    .add(BestInteriorBox)
                    .add(BestPaintBox)
                    .add(RebelsChoiceBox)
                    .add(ParticipantChoiceBox))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(JudgeSheetSubPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(JS_SaveButton)
                    .add(judgingSheetWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(504, 504, 504))
        );

        judgingSheetWait.getAccessibleContext().setAccessibleName("JudgingSheetWait");
        ((myJTabbedPane)tabbedPane).addMarker(judgingSheetWait);
        judgingSheetWait.setVisible(false);

        org.jdesktop.layout.GroupLayout JudgeSheetPanelLayout = new org.jdesktop.layout.GroupLayout(JudgeSheetPanel);
        JudgeSheetPanel.setLayout(JudgeSheetPanelLayout);
        JudgeSheetPanelLayout.setHorizontalGroup(
            JudgeSheetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgeSheetPanelLayout.createSequentialGroup()
                .add(JudgeSheetSubPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 139, Short.MAX_VALUE))
        );
        JudgeSheetPanelLayout.setVerticalGroup(
            JudgeSheetPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgeSheetPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(JudgeSheetSubPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tabbedPane.addTab("Judging Sheet", JudgeSheetPanel);

        JudgingPanel.setName("JudgingPanel"); // NOI18N

        CarScores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "<html>Registration<br/>Number</html>", "Class", "Owner", "Vehicle", "Judge #1", "Score #1", "Judge #2", "Score #2", "Printed"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        CarScores.setAutoCreateRowSorter(true);
        CarScores.setFillsViewportHeight(true);
        JudgingPane.setViewportView(CarScores);
        CarScores.getColumnModel().getColumn(0).setResizable(false);
        CarScores.getColumnModel().getColumn(1).setResizable(false);
        CarScores.getColumnModel().getColumn(4).setResizable(false);
        CarScores.getColumnModel().getColumn(5).setResizable(false);
        CarScores.getColumnModel().getColumn(6).setResizable(false);
        CarScores.getColumnModel().getColumn(7).setResizable(false);

        JudgingWait.setEnabled(false);
        JudgingWait.setName("JudgingWait"); // NOI18N
        JudgingWait.setText("Wait...");

        org.jdesktop.layout.GroupLayout JudgingPanelLayout = new org.jdesktop.layout.GroupLayout(JudgingPanel);
        JudgingPanel.setLayout(JudgingPanelLayout);
        JudgingPanelLayout.setHorizontalGroup(
            JudgingPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgingPanelLayout.createSequentialGroup()
                .add(JudgingPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(JudgingPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(JudgingPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 887, Short.MAX_VALUE))
                    .add(JudgingPanelLayout.createSequentialGroup()
                        .add(390, 390, 390)
                        .add(JudgingWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        JudgingPanelLayout.setVerticalGroup(
            JudgingPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(JudgingPanelLayout.createSequentialGroup()
                .add(23, 23, 23)
                .add(JudgingPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(JudgingWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        JudgingWait.getAccessibleContext().setAccessibleName("JudgingWait");
        ((myJTabbedPane)tabbedPane).addMarker(JudgingWait);
        JudgingWait.setVisible(false);

        tabbedPane.addTab("Judging", JudgingPanel);

        AwardsPanel.setName("AwardsPanel"); // NOI18N

        ReportTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "<html><div >Registration<br />Number</div></html>", "Class", "Owner", "Year", "Color", "Make", "Model", "Score"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        ReportTable.setName("ReportTable");
        AwardsPane.setViewportView(ReportTable);
        ReportTable.getColumnModel().getColumn(0).setResizable(false);
        ReportTable.getColumnModel().getColumn(3).setResizable(false);
        ReportTable.getColumnModel().getColumn(7).setResizable(false);

        AwardsPrintButton.setText("Print");
        AwardsPrintButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AwardsPrintButtonActionPerformed(evt);
            }
        });

        AwardsSaveResultsButton.setText("Save Results");
        AwardsSaveResultsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AwardsSaveResultsButtonActionPerformed(evt);
            }
        });

        AwardsWait.setEnabled(false);
        AwardsWait.setName("AwardsWait"); // NOI18N
        AwardsWait.setText("Wait...");

        MostClubMembers.setName("MostClubMembers");

        MostClubsLabel.setText("Most Represented Clubs");

        SecondMostClub.setName("SecondMostClub");

        org.jdesktop.layout.GroupLayout AwardsPanelLayout = new org.jdesktop.layout.GroupLayout(AwardsPanel);
        AwardsPanel.setLayout(AwardsPanelLayout);
        AwardsPanelLayout.setHorizontalGroup(
            AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(AwardsPanelLayout.createSequentialGroup()
                .add(AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(AwardsPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(AwardsPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 846, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(AwardsPanelLayout.createSequentialGroup()
                        .add(44, 44, 44)
                        .add(AwardsSaveResultsButton)
                        .add(70, 70, 70)
                        .add(AwardsPrintButton)
                        .add(54, 54, 54)
                        .add(AwardsWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(26, 26, 26)
                        .add(MostClubsLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(MostClubMembers)
                            .add(SecondMostClub))))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        AwardsPanelLayout.setVerticalGroup(
            AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(AwardsPanelLayout.createSequentialGroup()
                .add(21, 21, 21)
                .add(AwardsPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 391, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(AwardsPrintButton)
                        .add(AwardsSaveResultsButton))
                    .add(AwardsWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(AwardsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(MostClubMembers, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(MostClubsLabel)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(SecondMostClub, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(106, Short.MAX_VALUE))
        );

        AwardsWait.getAccessibleContext().setAccessibleName("AwardsWait");
        ((myJTabbedPane)tabbedPane).addMarker(AwardsWait);
        AwardsWait.setVisible(false);

        tabbedPane.addTab("Awards Report", AwardsPanel);

        AdminPanel.setName("AdminPanel"); // NOI18N

        ContestNameLabel.setText("Car Show Contest Name");

        ContestName.setText("The Amazing Midwest Car Spectacular");

        ShowDateLabel.setText("Car Show Date");

        ShowLocationLabel.setText("Show Location");

        ShowDate.setText("July 14, 2011");

        ShowLocation.setText("Lincoln, Nebraska");

        ServerNameLabel.setText("Scoring Server");

        ScoringServerName.setText(defaultServer);
        ScoringServerName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ScoringServerNameFocusLost(evt);
            }
        });

        AdminWait.setEnabled(false);
        AdminWait.setName("AdminWait"); // NOI18N
        AdminWait.setText("Wait...");

        debugButton.setText("Debug");
        debugButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                debugButtonActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel1.setText("Do not press this unless instructed");

        IPAddrLabel.setText("This System IP");

        jLabel2.setText(myIpAddress);

        jButton1.setText("Save");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveAdminActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout AdminPanelLayout = new org.jdesktop.layout.GroupLayout(AdminPanel);
        AdminPanel.setLayout(AdminPanelLayout);
        AdminPanelLayout.setHorizontalGroup(
            AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(AdminPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(AdminPanelLayout.createSequentialGroup()
                        .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(AdminPanelLayout.createSequentialGroup()
                                .add(ServerNameLabel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(ScoringServerName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 228, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(57, 57, 57)
                                .add(AdminWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, AdminPanelLayout.createSequentialGroup()
                                .add(IPAddrLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                                .add(18, 18, 18)
                                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(AdminPanelLayout.createSequentialGroup()
                                        .add(debugButton)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(jLabel1))
                                    .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE))))
                        .add(143, 143, 143))
                    .add(AdminPanelLayout.createSequentialGroup()
                        .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(ContestNameLabel)
                            .add(ShowDateLabel)
                            .add(ShowLocationLabel))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jButton1)
                            .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(ContestName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                                .add(ShowDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 160, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(ShowLocation)))
                        .add(0, 0, Short.MAX_VALUE)))
                .add(336, 336, 336))
        );
        AdminPanelLayout.setVerticalGroup(
            AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(AdminPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ContestNameLabel)
                    .add(ContestName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ShowDateLabel)
                    .add(ShowDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ShowLocationLabel)
                    .add(ShowLocation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jButton1)
                .add(164, 164, 164)
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(ServerNameLabel)
                        .add(ScoringServerName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(AdminWait, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(IPAddrLabel)
                    .add(jLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(AdminPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(debugButton)
                    .add(jLabel1))
                .addContainerGap(201, Short.MAX_VALUE))
        );

        AdminWait.getAccessibleContext().setAccessibleName("AdminWait");
        ((myJTabbedPane)tabbedPane).addMarker(AdminWait);
        AdminWait.setVisible(false);

        tabbedPane.addTab("Administration", AdminPanel);

        org.jdesktop.layout.GroupLayout wrapperPanelLayout = new org.jdesktop.layout.GroupLayout(wrapperPanel);
        wrapperPanel.setLayout(wrapperPanelLayout);
        wrapperPanelLayout.setHorizontalGroup(
            wrapperPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(wrapperPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(tabbedPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 912, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        wrapperPanelLayout.setVerticalGroup(
            wrapperPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(wrapperPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(tabbedPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 606, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(wrapperPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(wrapperPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 27, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * Add Registration panel Add Entrant Button action handler.  This
     * validates the Registration form and initiates an add or change depending
     * upon the event (Add Entrant or Change)
     * @param evt event triggering this action performed
     */
    private void AddEntrantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddEntrantActionPerformed
        // Validate inputs for completeness (all entries present except
        // the entrant # which the DB will provide.
        regWait.setVisible(true);  // indicate we are waiting on Entry Reg form
        String currEntNum = null;
        String request = null;
        String clubrequest = null;
        String fname = null;
        String lname = null;
        String addr = null;
        String city = null;
        String state = null;
        String phone = null;
        String zip = null;
        String year = null;
        String make = null;
        String model = null;
        String club = null;
        String color = null;
        String eclass = null;
        String park = null;

        if(FirstName.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "First name is empty. Please enter" +
                " a first name for the entrant.",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            FirstName.requestFocus();
            return;
        }
        else if (LastName.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Last name is empty. Please enter" +
                " a last name for the entrant.",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            LastName.requestFocus();
            return;
        }
        else if (EntrantAddress.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Address is empty. Please enter" +
                " an address for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantAddress.requestFocus();
            return;
        }
        else if (EntrantCity.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "City is empty. Please enter" +
                " a city name for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantCity.requestFocus();
            return;
        }
        else if(EntrantState.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "State is name empty. Please enter" +
                " a state name for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantState.requestFocus();
            return;
        }
        // uncomment if you want Phone # entry required
/*        else if(EntrantPhone.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Phone is empty. Please enter" +
                " a phone number for the entrant or a fictious value if" +
                "entrant does not want to provide their phone number.",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantPhone.requestFocus();
            return;
        } */
        else if(EntrantZipCode.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Zip code is empty. Please enter" +
                " a postal zip code for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantZipCode.requestFocus();
            return;
        }
        else if(EntrantModel.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Car Model is empty. Please enter" +
                " a car model name for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantModel.requestFocus();
            return;
        }
        else if(EntrantYear.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Car year is empty. Please enter" +
                " the manufacturing year for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantYear.requestFocus();
            return;
        }
        else if(EntrantMake.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Car Make is empty. Please enter" +
                " the manufacturer name for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantMake.requestFocus();
            return;
        }
        // uncomment if you want the parking field presence enforced
        /* else if(EntrantParking.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Parking location is empty. Please enter" +
                " a parking location for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantParking.requestFocus();
            return;
        } */
        else if(EntrantColor.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Car Color is empty. Please enter" +
                " a color for the entrant",
                "Invalid Entrant Data", JOptionPane.ERROR_MESSAGE);
            EntrantColor.requestFocus();
            return;
        }

        else {
            // the replaceAll removes any double-quote chars from the strings,
            // Only these will hose us because we use double-quotes to demarcate
            // string boundaries in our SQL statements.
            fname = FirstName.getText().replaceAll("\"","").replaceAll(", ",". ").trim();
            lname = LastName.getText().replaceAll("\"","").replaceAll(", ",". ").trim();
            eclass = ((String) EntrantClass.getSelectedItem());
            if(eclass.equals("")) eclass="PRE"; // default to PRE if not specified
            else eclass = eclass.substring(0,eclass.indexOf(" ")); // trim to first space in class string for mnemonic
            addr = EntrantAddress.getText().replaceAll("\"","").replaceAll(",",".").trim();
            city = EntrantCity.getText().replaceAll("\"","").replaceAll(",",".").trim();
            state = EntrantState.getText().replaceAll("\"","").replaceAll(",",".").trim();
            zip = EntrantZipCode.getText().replaceAll("\"","").replaceAll(",",".").trim();
            phone = EntrantPhone.getText().replaceAll("\"","").replaceAll(",",".").trim();
            make = EntrantMake.getText().replaceAll("\"","").replaceAll(",",".").trim();
            model = EntrantModel.getText().replaceAll("\"","").replaceAll(",",".").trim();
            color = EntrantColor.getText().replaceAll("\"","").replaceAll(",",".").trim();
            year = EntrantYear.getText().replaceAll("\"","").replaceAll(",",".").trim();
            park = EntrantParking.getText().replaceAll("\"","").replaceAll(",",".").trim();
            //if(PreRegButton.isSelected())
            //    prereg = "1";
            //else 
            //prereg = "0";
            if(evt.getActionCommand().equals("Change")) {
                in_update = true;
            } else in_update = false;
            currEntNum = EntrantNumber.getText().replaceAll("\"","").trim();
        }
        if(!EntrantClub.getSelectedItem().equals("")) {
            // if the entrant club is not empty we need to eval if it is a
            // new club (to add to Clubs table) or an existing club which we
            // just store in the Entrants table.
            club = ((String) EntrantClub.getSelectedItem()).trim();
            if(!checkClub(club))
                clubrequest = "insert into Clubs (club) values (\""+ club + "\");";
        }
        else {
            club = ""; // put an empty string into DB
        }
        //int eyear = Integer.parseInt(year);
        int ppreg = 0;
        // determine if this is a new entrant or an entrant change
        if(in_update) {
            request = "update "+ SQLiteCommandHandler.Entrants +
                " set fname = \""+fname+"\", lname = \""+lname+"\", mnemonic = \""
                +eclass+"\", address = \""+addr+"\", city = \""+city+"\","
                +" state = \""+state+"\", zip = \""+zip+"\", phone = \""
                +phone+"\", make = \""+make+"\", model = \""
                +model+"\", color = \""+color+"\", year = "+
                year+", parking_loc = \""+park+"\", club = \""+club+"\", preg = "+ppreg+
                " where entrant_num = "+currEntNum;
        }
        else {
            request = "insert into " + SQLiteCommandHandler.Entrants +
                " (fname,lname,mnemonic,address,city,state,zip," +
                "phone,make,model, color, year, parking_loc, club, preg )" +
                " values ( \"" + fname + "\" ,\"" + lname + "\", \"" + eclass +
                "\", \"" + addr + "\", \"" + city + "\", \"" + state + "\", \"" +
                zip + "\", \"" + phone + "\", \"" + make + "\", \"" + model +
                "\", \"" + color + "\", " + year + ", \"" + park + "\", \"" + club +
                "\", " + ppreg + " );";
        }
        regWait.setEnabled(true);
        regWait.setVisible(true); // set waiting condition for sqlPut()
        //((myJTabbedPane)tabbedPane).setActiveComponent(RegistrationPanel);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        int ret = sqlPut(RegistrationPanel, request);
        waitForIt(regWait);
        
        if(debug) logger.log(Level.INFO,"AddEntActionPerf: post RegWait loop");
        if(debug) logger.log(Level.INFO,"performing club request, clientSocket state is");
        if(debug) {
            if(clientSocket == null) logger.log(Level.INFO,"null");
            else {
                logger.log(Level.INFO,"non-null, "+clientSocket.toString());
                if(clientSocket.isClosed()) logger.log(Level.INFO,"clientSocket is closed");
                if(clientSocket.isConnected()) logger.log(Level.INFO,"clientSocket is connected");
                if(clientSocket.isBound()) logger.log(Level.INFO,"clientSocket is bound");
            }
        }
        if(clubrequest != null) {
            //EntrantClub.requestFocus();
            regWait.setEnabled(true);
            regWait.setVisible(true);
            if(debug) logger.log(Level.INFO,"AddEntActionPerf: insert club into Clubs");
            //((myJTabbedPane)tabbedPane).setActiveComponent(EntrantClub);
        if(taskStackStatus(false)) { taskStackStatus(true); }
            ret = sqlPut(EntrantClub, clubrequest);
            waitForIt(regWait);
        }
        // detect if we received an update to the entrant #, if not request it
        if(!EntrantNumber.getText().equals("")) {
            if(debug) logger.log(Level.INFO,"AddEntActPerf: set RegPrint On");
            RegPrint.setVisible(true);
            EntrantClub.setSelectedItem(club);
        }
        else {
            logger.log(Level.INFO,"AddEntActPerf: firing search on no ent# ret");
            ActionEvent ae = new ActionEvent(EntrantSearch,
                ActionEvent.ACTION_PERFORMED, "Search Entrant");
            java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ae);
            //EntrantSearchActionPerformed(ae);
        }
        // Here is the auto-printing capability.  Per DTO & customer, the
        // algorithm is as follows:
        // if parking-number != empty (isset) & !printed already
        // & class != PRE
        // 5/28/12 added to the condition if entrant_number != "" (empty)
        // given our problems with DB reply path comms, this seemed prudent
        // because the form print requires a valid entrant # on the screen
        logger.log(Level.INFO,"EP: "+EntrantParking.getText()+
            ", EC: "+EntrantClass.getSelectedItem()+
            ", ThisEntrantPrinted: "+ThisEntrantPrinted);
        if(!EntrantParking.getText().equals("") & !EntrantNumber.getText().equals("") &
            !((String)EntrantClass.getSelectedItem()).substring
            (0,((String)EntrantClass.getSelectedItem()).indexOf(" ")).equals("PRE")
            & !ThisEntrantPrinted) {
                printScoringSheets();
        }
        //}
        FirstName.requestFocus();
}//GEN-LAST:event_AddEntrantActionPerformed

    /**
     * check if the supplied club is already known in the CarShowUI
     * field containing the list of known Clubs which is populated in
     * the last call of setRegClubs().
     * @param clubname
     * @return
     */
    private boolean checkClub(String clubname) {
        boolean foundClub=false;
        if(activeClubs == null) {
            foundClub = false;
        }
        else if(activeClubs.length > 0) {
            for (int i = 0; i < activeClubs.length; i++) {
                if (activeClubs[i] != null && activeClubs[i].equals(clubname))
                    foundClub=true;
            }
        }
        return foundClub;
    }


    private void EntrantSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EntrantSearchActionPerformed
        // Entrant number search by button press instead of tab-out of field
        // check first for EntrantNumber primary key supplied in search
        if(debug) logger.log(Level.INFO,"EntSearchActPerf: entry, evt:"+evt.getActionCommand());
        if (!EntrantNumber.getText().equals("") && !focusSearch) {
            int entNum = new Integer(EntrantNumber.getText()).intValue();
            if(entNum > 0) {
                if(debug) logger.log(Level.INFO,"EntSearchActPerf: get by id path used...");
                regWait.setVisible(true);
                String request = "select * from Entrants where entrant_num="+entNum+";";
                if(taskStackStatus(false)) { taskStackStatus(true); }
                sqlGet(RegistrationPanel, request);
                waitForIt(regWait);
            }
            else clearEntrant();
        } // Try using first/last name for search if supplied
        else if (!focusSearch && ! LastName.getText().equals("") & ! FirstName.getText().equals("")) {
            regWait.setEnabled(true);
            regWait.setVisible(true);
            String request = "select * from Entrants where fname like\"%"+
                FirstName.getText().trim()+"%\" and lname like \"%"+LastName.getText().trim()+"%\";";
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlGet(RegistrationPanel, request);
            waitForIt(regWait);
        } // if !entrantNumber nor first/last name, search on other data
        else if(!focusSearch) {
            StringBuilder sb = new StringBuilder();
            sb.append("select * from Entrants where ");
            java.util.Set<String> keyset = EntrantFields.keySet();
            Iterator kiter = keyset.iterator();
            boolean noAnd = true;
            boolean conditions = false;
            while(kiter.hasNext()) {
                String currKey = (String)kiter.next();
                javax.swing.JComponent c = EntrantFields.get(currKey);
                if(c instanceof javax.swing.JComboBox) {
                    String val = (String)((javax.swing.JComboBox)c).getSelectedItem();
                    if(val != null && !val.equals("")) {
                        conditions = true;
                        if(!noAnd) sb.append(" and ");
                        if(currKey.equals("mnemonic"))
                            sb.append(currKey+"=\""+val.substring(0,val.indexOf(" "))+"\" ");
                        else sb.append(currKey+"=\""+val+"\"");
                        noAnd = false;
                    }
                }
                else { // JTextField instance
                    String val = ((javax.swing.JTextField)c).getText();
                    if(val != null && !val.equals("")) {
                        conditions = true;
                        if(!noAnd) sb.append(" and ");
                        sb.append(currKey+" like \"%"+val+"%\" ");
                        noAnd = false;
                    }
                }
            }
            if(conditions) { // ensure we have a valid SQL stmt with where clause(s)
                regWait.setEnabled(true);
                regWait.setVisible(true);
                if(taskStackStatus(false)) { taskStackStatus(true); }
                sqlGet(RegistrationPanel, sb.toString());
                waitForIt(regWait);
            }
            else { // if we didnt find any search conditions do this...
                if(debug) logger.log(Level.INFO,"entrantSearch: sql query without conditions: "+sb.toString());
                clearEntrant();
            }
        }
        focusSearch = false;
        // TODO - THIS NEXT SHOULD MOVE TO THE REPLY PATH SO WE DONT PUT UP A
        // PRINT BUTTON ON A FAILIED SEARCH
        if(!EntrantNumber.getText().equals("")) {
            if(debug) logger.log(Level.INFO,"EntSearchActPerf: set RegPrint On");
            RegPrint.setVisible(true);
            FirstName.requestFocus();
        }
        else { 
            RegPrint.setVisible(false);
            EntrantParking.requestFocus();
        }
    }//GEN-LAST:event_EntrantSearchActionPerformed

    private void EntrantClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EntrantClearActionPerformed
        clearEntrant();
        if(activeClubs != null && activeClubs.length > 0) {
            if(EntrantClub.getItemCount() != activeClubs.length) {
                // this sets 'larger' to the larger of the two values, its
                // a weird syntax of Java that makes this decide & set really
                // compact code but hard to understand for non-Java pros
                if (EntrantClub.getItemCount() < activeClubs.length) {
                    for(int i = 0; i < activeClubs.length; i++) {
                        if(!EntrantClub.getItemAt(i).equals(activeClubs[i]))
                            EntrantClub.addItem(activeClubs[i]);
                    }
                }
            }
        }
        AddEntrant.setText("Add Entrant");
        RegPrint.setVisible(false);
        EntrantParking.requestFocus();
    }//GEN-LAST:event_EntrantClearActionPerformed

    private void AddClassButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddClassButtonActionPerformed
        if(debug) logger.log(Level.INFO,"AddClassActionPerformed fired...");
        int currYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);
        if(NewClassMnemonic.equals("")) {
                JOptionPane.showMessageDialog(tabbedPane,
                "New class label is empty. Please enter" +
                " a class label for the new or changing class.",
                "Class Data", JOptionPane.ERROR_MESSAGE);
                NewClassMnemonic.requestFocus();
                return;
        }
        else if ( NewClassName.equals("")) {
                 JOptionPane.showMessageDialog(tabbedPane,
                "New class name is empty. Please enter" +
                " a name describing the class limitations or inclusions.",
                "Class Data", JOptionPane.ERROR_MESSAGE);
                 NewClassName.requestFocus();
                 return;
        }
            
        else if (NewClassStartYear.equals("") || !checkNum(NewClassStartYear.getText())) {
                JOptionPane.showMessageDialog(tabbedPane,
                "Starting year of class is not a number. Please enter" +
                " a starting year for the class.",
                "Class Data", JOptionPane.ERROR_MESSAGE);
                NewClassStartYear.requestFocus();
                return;
        } 
        
        else if ( NewClassEndYear.equals("") || !checkNum(NewClassEndYear.getText())) {
                JOptionPane.showMessageDialog(tabbedPane,
                "Ending year for the class is empty. Please enter" +
                " an ending year for the class.",
                "Class Data", JOptionPane.ERROR_MESSAGE);
                NewClassEndYear.requestFocus();
                return;
        }
        else if (Integer.parseInt(NewClassStartYear.getText()) < 1885) {
                JOptionPane.showMessageDialog(tabbedPane,
                    "Class starting year is before 1885," +
                    " which is the year Karl Benz built the first automobile." +
                    "Please enter a valid production year range for the new class.",
                    "Class Data", JOptionPane.ERROR_MESSAGE);
                NewClassStartYear.requestFocus();
                return;
        }
        else if (Integer.parseInt(NewClassEndYear.getText()) > currYear) {
                    JOptionPane.showMessageDialog(tabbedPane,
                      "Class ending year is in the future. Please enter a" +
                      " valid production year range for the new class.",
                      "Class Data", JOptionPane.ERROR_MESSAGE);
                    NewClassEndYear.requestFocus();
                    return;
        }
        if(!(activeClasses == null)) {
            for (int i = 0; i < activeClasses.length; i++) {
                // audit the classes and see if there is a preexisting class
                // of this name.  This is unnecessary given we check this on
                // focusLost events for this field, however...
                if(activeClasses[i].equals(NewClassMnemonic.getText())) {
                    JOptionPane.showMessageDialog(tabbedPane,
                      "Class label is already in use. Please choose a" +
                      " different label for this new class.",
                      "Class Data", JOptionPane.ERROR_MESSAGE);
                    NewClassMnemonic.requestFocus();
                    return;
                }
            }
            String[] nact = new String[activeClasses.length+1];
            System.arraycopy(activeClasses,0,nact,0,activeClasses.length);
            activeClasses = nact;
            activeClasses[activeClasses.length-1] = NewClassMnemonic.getText().
                replaceAll(",",".").replaceAll("\"","").trim();
        }
        else {
            activeClasses = new String[1];
            String[] nact = new String[activeClasses.length+1];
            System.arraycopy(activeClasses, 0, nact, 0, activeClasses.length);
            activeClasses[0] = NewClassMnemonic.getText().replaceAll(",",".").
                replaceAll("\"","").trim();
        }
        String request = "insert into JudgeClasses "+
            "('mnemonic', 'classname', 'StartYear', 'EndYear') values (\""+
            NewClassMnemonic.getText().replaceAll(",",".").replaceAll("\"","").trim()+"\",\""+
            NewClassName.getText().replaceAll(",",".").replaceAll("\"","").trim()+
            "\","+Integer.parseInt(NewClassStartYear.getText())+","+
            Integer.parseInt(NewClassEndYear.getText())+")";
        if(debug) logger.log(Level.INFO,"ClassAddActPerf: sql request: "+request);

        ClassWait.setEnabled(true);
        ClassWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        int ret = sqlPut(ClassListTable, request);
        waitForIt(ClassWait);
        NewClassMnemonic.requestFocus();
    }//GEN-LAST:event_AddClassButtonActionPerformed

    private void DeleteClassButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteClassButtonActionPerformed
        if(ClassListTable.getSelectedRow() < 0) {
            if(debug) logger.log(Level.INFO,"DeleteClassBtnActPerf: no row selected in tbl!");
        }
        else {
            int drow = ClassListTable.getSelectedRow();
            Object cclass = ClassListTable.getValueAt(drow,0);
            if(cclass.equals("")) {
                ((javax.swing.table.DefaultTableModel)ClassListTable.getModel()).removeRow(drow);
                ClassListTable.clearSelection();
                return;
            }
            // this is an early-out if they try to delete the PRE class...
            if(((String)cclass).equals("PRE")) {
                JOptionPane.showMessageDialog(tabbedPane,
                    "The PRE class is used internally to mark the registrations\n" +
                    " that have not completed all registration tasks.\n"+
                    "You are _not_ allowed to delete this class.",
                    "Class Data", JOptionPane.ERROR_MESSAGE);
                NewClassMnemonic.requestFocus();
                ClassListTable.clearSelection();
                return;
            }
            String request = "delete from "+SQLiteCommandHandler.JudgeClasses+
                " where mnemonic = \""+(String)cclass+ //"\" and classname=\""+
                "\"";
            ClassWait.setEnabled(true);
            ClassWait.setVisible(true);
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(ClassListTable, request);
            waitForIt(ClassWait);
        }
        NewClassMnemonic.requestFocus();
    }//GEN-LAST:event_DeleteClassButtonActionPerformed

    /**
     * print the Awards Report panel.
     * @param evt print button event
     */
    private void AwardsPrintButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AwardsPrintButtonActionPerformed
        javax.print.attribute.HashPrintRequestAttributeSet set = 
                new javax.print.attribute.HashPrintRequestAttributeSet();
        set.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE);
        Object[] vals = { ContestName.getText(), HostingClubName };
        java.text.MessageFormat header = new java.text.MessageFormat( //"{0}{1}");
            ContestName.getText()+" Hosted By "+HostingClubName);
        header.format(vals);
        
        java.text.MessageFormat footer = new java.text.MessageFormat(ShowDate.getText());
        java.awt.Font ofont = ReportTable.getFont();
        // Comment this font setting out for Landscape printing below...
        java.awt.Font nfont = new java.awt.Font("TableFont", java.awt.Font.PLAIN, 12);
        ReportTable.setFont(nfont);
        javax.swing.table.TableColumn column = null;
        column = ReportTable.getColumnModel().getColumn(0);
        column.setMinWidth(110);
        try {
            ReportTable.print(javax.swing.JTable.PrintMode.FIT_WIDTH, header, footer, true,  set, true);
            //ReportTable.print(javax.swing.JTable.PrintMode.FIT_WIDTH);
        } catch (java.awt.print.PrinterException pe) {
            logger.log(Level.SEVERE,"error printing awards report");
        }
        column.setMaxWidth(70);
        ReportTable.setFont(ofont);
    }//GEN-LAST:event_AwardsPrintButtonActionPerformed

    /**
     * Save a copy of the database tables to CSV files for portable database
     * saving.  This routine uses the ReportTable as the key object to inform
     * the sqlClientReader what requested the data, and cause sqlClientReader
     * to create the database dump data.
     * @param evt 
     */
    private void AwardsSaveResultsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AwardsSaveResultsButtonActionPerformed
        String request = "Save";  // use a keyword command to the DB
        AwardsWait.setEnabled(true);
        AwardsWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(ReportTable, request);
    }//GEN-LAST:event_AwardsSaveResultsButtonActionPerformed

    /**
     * Implements the search capability from the Registration panel on entry
     * of a registration number.
     * @param evt 
     */
    private void EntrantNumberFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_EntrantNumberFocusLost
        if(debug) logger.log(Level.INFO,"EntNumFocusLost: entry evt:"+evt.paramString());
        focusSearch = true;
        if (! EntrantNumber.getText().equals("")) {
            int entNum = -1;
            try {
                entNum = new Integer(EntrantNumber.getText()).intValue();
            } 
            catch (NumberFormatException nfe) {
                EntrantNumber.setText("");
                EntrantParking.requestFocus();
                return;
            }
            if(entNum > 0) {
                regWait.setEnabled(true);
                regWait.setVisible(true);
                String request = "select * from Entrants where entrant_num="+entNum+";";
                if(taskStackStatus(false)) { taskStackStatus(true); }
                sqlGet(RegistrationPanel, request);
                waitForIt(regWait);
            }
            else {
                clearEntrant();
                EntrantParking.requestFocus();
                focusSearch = false;
            }
        }
        if(!EntrantNumber.getText().equals("")) {
            if(debug) logger.log(Level.INFO,"EntNumFocusLost: turn On RegPrint");
            RegPrint.setVisible(true);
        }
    }//GEN-LAST:event_EntrantNumberFocusLost

    /**
     * Detects the change of the scoring server value on the Administration
     * panel and changes the setting for all subsequent DB calls to this new
     * server name.
     * @param evt 
     */
    private void ScoringServerNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ScoringServerNameFocusLost
        // set the global setting that is used by the SqlClientReader
        if(debug) logger.log(Level.INFO,"ScoringServerNameFocusLost: fired");
        boolean changed = false;
        if (ScoringServerName.getText().equals("")) {
            ScoringServerName.setText(defaultServer);
            changed = true; // dont know what it was before but empty is right out
        }
        else if(ScoringServerName.getText().equals(SQLServer)) {
            changed = false;
        }
        else if(ScoringServerName.getText().equals(defaultServer)) {
            changed = true;
        }
        else if(ScoringServerName.getText()
            .matches("[0-9]{2,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?")) {
            SQLServer = ScoringServerName.getText().trim();
            changed = true;
        }
        else {
            JOptionPane.showMessageDialog(tabbedPane,
                "Scoring Server is set to a machine name" +
                " but this will fail unless you have a DNS, use the IP-v4 address",
                "of the scoring server, NNN.NNN.NNN.NNN", JOptionPane.ERROR_MESSAGE);
                ScoringServerName.requestFocus();
        }
        if (changed) {
            disconnect();
            clearLocalTables();
        }
        if(debug) logger.log(Level.INFO,"ScoringServerNameFocusLost: ScoringServerName: "+SQLServer);
    }//GEN-LAST:event_ScoringServerNameFocusLost

    private void ClassSetPanelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ClassSetPanelFocusGained
        if(debug) logger.log(Level.INFO,"ClassSetPanelFocusGained fired");
        initClassTable();
    }//GEN-LAST:event_ClassSetPanelFocusGained

    private void RegPanelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_RegPanelFocusGained
        // When focus gained / restored to Registration Pane
        // request the classes and clubs lists and populate the dropdowns
        if(debug) logger.log(Level.INFO,"RegPanelFocusGained: event fired...:");
        if (!in_init) {
            initRegistration();
        }
    }//GEN-LAST:event_RegPanelFocusGained

    /**
     * Initialize the Registration Panel upon first selection or focus gained.
     * This will change the cursor to a hand, and tries to implement a wait
     * cursor when the class field waitLit is true.  That gets set to true
     * in the waitForIt() method, which is watching the objects on the screen
     * and the background SqlClientReader for the reply.
     */
    private void initRegistration() {
        regWait.setVisible(true);
        // initialize a cursor that differs from the standard with this code
        tabbedPane.addMouseMotionListener(new java.awt.event.MouseMotionListener() {
        @Override
        public void mouseMoved(java.awt.event.MouseEvent e) {
            // use this next bit for targeting the mouse more
            final int x = e.getX();
            final int y = e.getY();
            // only display a hand if the cursor is over the items
            java.awt.Rectangle cellBounds = tabbedPane.getBounds();
            if (cellBounds != null && cellBounds.contains(x, y) && waitLit) {
                tabbedPane.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
            } else {
               tabbedPane.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
            }
        }
        
        @Override
        public void mouseDragged(java.awt.event.MouseEvent e) {
        }
    });
        // default selection of hidden Pre-Reg selector button
        int itemcnt = EntrantClass.getItemCount();
        if(itemcnt == 0) {
            if(debug) logger.log(Level.INFO,"initReg: EntrantClass has 0 items");
            initClassList();
        }
        try {
            Thread.sleep(300);
        } catch (InterruptedException ie) {
            logger.log(Level.INFO,"initReg: sleep btwn field inits interrupted...");
        }
        itemcnt = EntrantClub.getItemCount();
        if(itemcnt == 0) {
            if(debug) logger.log(Level.INFO,"initReg: EntrantClub has 0 items");
            initClubsList();
        }
        EntrantParking.requestFocus();
        EntrantDeleteButton.setEnabled(false);
        if(debug) logger.log(Level.INFO,"initReg: done");
    }
    
    /**
     * This sets the order of tab traversal on the Registration Panel.
     * 
     */
    private void setRegFocusTraversal() {
            javax.swing.FocusManager fm = javax.swing.FocusManager.getCurrentManager();
            javax.swing.JRootPane jrp = RegistrationPanel.getRootPane();
            java.util.Vector<java.awt.Component> flds = new java.util.Vector();
            flds.add(EntrantParking);
            flds.add(FirstName);
            flds.add(LastName);
            flds.add(EntrantAddress);
            flds.add(EntrantCity);
            flds.add(EntrantState);
            flds.add(EntrantZipCode);
            flds.add(EntrantPhone);
            flds.add(EntrantYear);
            flds.add(EntrantMake);
            flds.add(EntrantModel);
            flds.add(EntrantColor);
            flds.add(EntrantClass);
            flds.add(EntrantClub);
            flds.add(EntrantNumber);
            flds.add(FirstName);
            //flds.add(AddEntrant);
            //flds.add(EntrantSearch);
            //flds.add(EntrantClear);
            //if(RegPrint.isEnabled()) flds.add(RegPrint);
            //flds.add(PreRegButton);
            //regLayoutFocusTraversalPolicy rftp = new regLayoutFocusTraversalPolicy(flds);
            regLayoutFocusTraversalPolicy rftp = new regLayoutFocusTraversalPolicy(flds);
            RegistrationPanel.setFocusTraversalPolicy(rftp);
            RegistrationPanel.setFocusCycleRoot(true);
    }
    /**
     * Handles which tab was selected on user context/task change.  Based on
     * the selected tab, take the appropriate init actions for that tab.
     */
    private void tabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabbedPaneStateChanged
        if (rTimer != null && rTimer.isRunning()) { 
            rTimer.stop();
            rTimer.removeActionListener(rptActionListener); //removes the one registered listener
            rTimer = null;
        }
        // This makes the enter key work as the Save button on the judging sheet
        getRootPane().setDefaultButton((javax.swing.JButton)actDefaultButton);
        javax.swing.JTabbedPane pane = (javax.swing.JTabbedPane)evt.getSource();
        //if(clientReader.isAlive()) {
        //    System.err.println("tabbedPaneStateChg: client reader alive on entry");
        //}
        int sel = pane.getSelectedIndex();
        switch (sel) {
            case 0:
                if(debug) logger.log(Level.INFO,"Registration Tab Focus Selected");
                if(!in_init) {
                    clearEntrant();
                    initClassList();
                    //int sleepcnt = 0;
                    if(regWait.isVisible()) { 
                        logger.log(Level.SEVERE,"tabbedPane stateChange"+
                            "regWait still lit after iniClassList()");
                        ((myJTabbedPane)tabbedPane).whichWaitActive();
                        ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantClass);
                    }
                    initClubsList();
                    if(regWait.isVisible()) {
                        logger.log(Level.SEVERE,"tabbedPane stateChange"+
                            "regWait still lit after iniClassList()");
                        ((myJTabbedPane)tabbedPane).whichWaitActive();
                        ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantClub);
                    }
                    EntrantDeleteButton.setEnabled(false);
                    EntrantParking.requestFocus();
                }
                else {
                    if(debug) logger.log(Level.INFO,"in_init defer initting...");
                }
                break;
            case 1:
                if(debug) logger.log(Level.INFO,"Class Admin Tab Selected");
                initClassTable();
                NewClassMnemonic.requestFocus();
                break;
            case 2:
                if(debug) logger.log(Level.INFO,"Judging Sheet Tab Selected");
                setSpecialAwards();
                JS_SaveButton.setForeground(java.awt.Color.BLACK);
                clearJudgingSheet((byte)7);
                getRootPane().setDefaultButton(JS_SaveButton);
                JS_EntrantNumber.requestFocus();
                break;
            case 3:
                if(debug) logger.log(Level.INFO,"Judging Tab Selected");
                schedReport();
                break;
            case 4:
                if(debug) logger.log(Level.INFO,"Awards Tab Selected");
                getAwardsReport();
                break;
            case 5:
                if(debug) logger.log(Level.INFO,"Admin Panel Selected");
                getAdminData();
                break;
            default:
                if(debug) logger.log(Level.INFO,"Unknown Tab Selected");
        }
    }//GEN-LAST:event_tabbedPaneStateChanged

    /**
     * This FocusLost block implements the search & populate function of the
     * Judging Sheet data entry operation.  The entered registration number
     * triggers the DB request to populate the form, if the data request
     * is for a non-existent registration number it clears the form for another
     * cycle.  If existing, it populate the form with the registration data
     * then proceeds to look for judging data from the Scoring table.  There
     * is a boolean flag set to indicate if there was Scoring data which is
     * used later in the Judging Sheet Save Action Performed block to indicate
     * a Scoring insert vs. an update operation.
     * @param evt 
     */
    private void JudgeSheetEntNumberFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JudgeSheetEntNumberFocusLost
        JS_SaveButton.setForeground(java.awt.Color.BLACK);
        if(debug) logger.log(Level.INFO,"JudgeSheetEntrantNumber Focus Lost fired!");
        if(!(JS_EntrantNumber.getText().equals(""))) {
            if(!(JS_EntrantNumber.getText().matches("[1-9][0-9]*"))) {
                JOptionPane.showMessageDialog(tabbedPane,
                    "Judge sheet entrant number is not a number (" +
                    JS_EntrantNumber.getText()+")",
                    "Judging Entrant Number Error", JOptionPane.ERROR_MESSAGE);
                JS_EntrantNumber.setText("");
                JS_EntrantNumber.requestFocus();
            }
            else {
                int entNum = new Integer(JS_EntrantNumber.getText()).intValue();
                if(currentJudgingEntrant == null || currentJudgingEntrant.equals(""))
                    currentJudgingEntrant = JS_EntrantNumber.getText();
                else {
                    if(!JS_EntrantNumber.getText().equals(currentJudgingEntrant))
                        clearJudgingSheet((byte)7); // clear entrant & judge scores
                }
                if(entNum > 0) {
                    String request = "select entrant_num, make, model, "+
                        "parking_loc, color, year, mnemonic, aw1, aw2 from "+
                        SQLiteCommandHandler.Entrants+
                        " where entrant_num = "+entNum;

                    judgingSheetWait.setEnabled(true);
                    judgingSheetWait.setVisible(true);
                    if(taskStackStatus(false)) { taskStackStatus(true); }
                    sqlGet(JudgeSheetPanel, request);
                    waitForIt(judgingSheetWait);
                    if(JS_EntrantNumber.getText().equals("")) {
                        if(debug) logger.log(Level.INFO,"JudgeEntNumActPerf: JS Ent# still empty!");
                        JS_EntrantNumber.requestFocus();
                        currentJudgingEntrant = "";
                        return;
                    }
                    else {
                        request = "select * from "+SQLiteCommandHandler.Scoring+
                            " where entrant_num = "+JS_EntrantNumber.getText();
                        judgingSheetWait.setEnabled(true);
                        judgingSheetWait.setVisible(true);
                        if(taskStackStatus(false)) { taskStackStatus(true); }
                        sqlGet(JudgeSheetSubPanel, request);
                        waitForIt(judgingSheetWait);
                    }
                    Iterator<javax.swing.JTextField> fiter = JudgingFields.iterator();
                    while(fiter.hasNext()) {
                        javax.swing.JTextField c = fiter.next();
                        if(c.getText().equals("")) {
                            c.requestFocus();
                            break;
                        }
                    }
                }
                else {
                    JS_EntrantNumber.setText("");
                    JS_EntrantNumber.requestFocus();
                }
                currentJudgingEntrant = JS_EntrantNumber.getText();
            }

        }
        else { // empty judging # specified, clear the form of non-active data
            clearJudgingSheet((byte)7); // clear entrant & judge scores
            JS_EntrantNumber.requestFocus();
        }
    }//GEN-LAST:event_JudgeSheetEntNumberFocusLost

    /**
     * Save the entered values on the Judging Sheet (judging data entry) form.
     * This is a really complicated bit of code that enforces the various
     * constraints on the judging data input.  A short list of these:
     * 1. Data entered must have judge initials
     * 2. Only 1 award allowed excepting Participants Choice
     * 3. Participants Choice can be assigned to anybody
     * 4. Valid (numeric, positive, non-zero) entrant registration number (obviously)
     * 5. Only numeric values in scores
     * 6. Scores within limits (1-20 or 1-10 depending on score category)
     * 
     * Internally, it also must be sensitive to first Scoring entry versus
     * subsequent (which really are when to use insert vs. update SQL statements)
     * It also needs to handle that corner case where one entrant could win
     * an award and also be given the Participants Choice award.
     * @param evt 
     */
    private void JudgeSheetSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JudgeSheetSaveActionPerformed
        if(debug) logger.log(Level.INFO,"JS_SaveActPerf: entry, evt:"+evt.getActionCommand());
        int boxesSeen = 0;  // use this as a preview for the save of 
        boolean deleteCase = false;
        boolean j1Populated = false;
        boolean j2Populated = false;
        // entrant # is a required field, if unset abort early
        if(!JS_EntrantNumber.getText().matches("[1-9][0-9]*")) {
            JOptionPane.showMessageDialog(tabbedPane,
                "Judge sheet entrant number is not a number (" +
                JS_EntrantNumber.getText()+")",
                "Judging Entrant Number Error", JOptionPane.ERROR_MESSAGE);
            JS_EntrantNumber.requestFocus();
            return;
        }
        else {
            String EntNum = JS_EntrantNumber.getText().trim();
            // validate fields & transmit to DB
            if(debug) logger.log(Level.INFO,"JdgSheetSaveActPerf: newScoreEntry: "+newScoreEntry);
            Iterator<javax.swing.JTextField> fiter = JudgingFields.iterator();
            while(fiter.hasNext()) {
                javax.swing.JTextField c = fiter.next();
                if(!c.getText().equals("")) {
                    if(!c.getText().matches("[0-9]*") && !c.getText().equals("")) {
                        if(EntNum.matches("[1-9][0-9]*")) {
                            JOptionPane.showMessageDialog(tabbedPane,
                                "Judge score entered is not a number (" +
                                c.getText()+")",
                                "Judging Score Entry Error", JOptionPane.ERROR_MESSAGE);
                            c.requestFocus();
                            return;
                        }
                    }
                    else {
                        int val = Integer.parseInt(c.getText());
                        String name = c.getName();
                        if(name.matches("j[12]_cat[1234]")) {
                            if (val > 20) {
                                JOptionPane.showMessageDialog(tabbedPane,
                                    "Judge score ("+c.getText()+") larger than permitted value 20",
                                    "Judging Score Entry Error", JOptionPane.ERROR_MESSAGE);
                                c.requestFocus();
                                return;
                            }
                        }
                        else {
                            if (val > 10) {
                                JOptionPane.showMessageDialog(tabbedPane,
                                    "Judge score ("+c.getText()+") larger than permitted value 10",
                                    "Judging Score Entry Error", JOptionPane.ERROR_MESSAGE);
                                c.requestFocus();
                                return;
                            }
                        }
                        if(name.matches("j1_cat[1-6]")) j1Populated = true;
                        else j2Populated = true;
                    }
                }
            }
            // VALIDATE AWARD BOXES, only one allowed for first 6, 7th can
            // be checked b/c of show rules (per DTO rqmts.)
            // shortcut relies on awardsChanged, check awards if awardsChanged
            if(awardsChanged) {
                int btnCount = 0;
                javax.swing.JCheckBox lastChecked = null;
                Iterator aiter = AwardsBoxes.iterator();
                while(aiter.hasNext()) {
                    javax.swing.JCheckBox c = (javax.swing.JCheckBox)aiter.next();
                    if(c.isSelected()) {
                        if(SpecialAwards.containsKey(c.getName())) {
                            // this award has already been assigned in our last
                            // lookup of the SpecialAwards data.  Eval if it's this
                            // entrant or a different one...
                            // empty is OK in the field btw...
                            if(!JS_EntrantNumber.getText().equals(SpecialAwards.get(c.getName()))
                                    && !SpecialAwards.get(c.getName()).equals("")) {
                                // Yes, they differ, so warn the user...
                                JOptionPane.showMessageDialog(tabbedPane,
                                    "The award "+c.getText()+" has already been awarded to "+
                                    " registration # "+SpecialAwards.get(c.getName()),
                                    "Judging Score Entry Error", JOptionPane.ERROR_MESSAGE);
                                //c.setSelected(false);
                                c.requestFocus();
                                return;
                            }
                        }
                        btnCount++;
                        boxesSeen++;
                        lastChecked = c;
                    }
                }
                if(boxesSeen > 1 && !ParticipantChoiceBox.isSelected()) {
                    // selected too many of the exclusive awards, find the last
                    // one selected & highlight it
                    JOptionPane.showMessageDialog(tabbedPane,
                        "Invalid awards selection - only Participants Choice can \n"+
                        "be selected along with another Specialty Award.  \nAll "+
                        "other awards are exclusive.", "Judging Score Entry Error", 
                        JOptionPane.ERROR_MESSAGE);
                    lastChecked.requestFocus();
                    return;
                }
                if(boxesSeen == 0) {
                    // remove award case
                    deleteCase = true;
                }
            }
        }
        String EntNum = JS_EntrantNumber.getText().trim();
        StringBuilder sb = new StringBuilder();
        boolean haveJI1 = false;
        boolean haveJI2 = false;
        if(!JS_JudgeInitials1.getText().equals("")) {
            haveJI1 = true;
        }
        if(!JS_JudgeInitials2.getText().equals("")) {
            haveJI2 = true;
        }
        if((!haveJI1 & j1Populated) || (!haveJI2 & j2Populated)) {
            JOptionPane.showMessageDialog(tabbedPane,
                "No judging initials entered",
                "Judging Score Entry Error", JOptionPane.ERROR_MESSAGE);
            if(!haveJI1 & j1Populated)
                JS_JudgeInitials1.requestFocus();
            else JS_JudgeInitials2.requestFocus();
            return;
        }
        // form score data stmt (what there is of it) send it to the server
        // depending upon if the award has been previously awarded we insert or update
        // or delete if deleteCase = true
        Iterator<javax.swing.JTextField> fiter = JudgingFields.iterator();
        if(newScoreEntry && EntNum != null && !EntNum.equals("") ) {  // insert Scoring data case
            sb.append("insert into ");
            sb.append(SQLiteCommandHandler.Scoring);
            sb.append(" ( ");
            sb.append("entrant_num");
            while(fiter.hasNext()) {
                javax.swing.JTextField c = fiter.next();
                //if(!c.getText().equals("")) {
                    sb.append(", ");
                    sb.append(c.getName());
                //}
            }
            sb.append(", Judge1 ");
            sb.append(", Judge2 ");
            sb.append(") values ( ");
            sb.append(EntNum);
            fiter = JudgingFields.iterator();
            while(fiter.hasNext()) {
                javax.swing.JTextField c = fiter.next();
                if(!c.getText().equals("")) {
                    sb.append(", ");
                    sb.append(c.getText());
                }
                else {
                    sb.append(", 0");
                }
            }
            sb.append(", \""+JS_JudgeInitials1.getText()+"\"");
            sb.append(", \""+JS_JudgeInitials2.getText()+"\"");
            sb.append(")");
        }
        else {  // update Scoring table data case
            sb.append("update ");
            sb.append(SQLiteCommandHandler.Scoring);
            sb.append(" set ");

            boolean firstparam = true;
            while(fiter.hasNext()) {
                javax.swing.JTextField c = fiter.next();
                if(!c.getText().equals("")) {
                    if(!firstparam) sb.append(", ");
                    else firstparam=false;
                    sb.append(c.getName());
                    sb.append(" = ");
                    sb.append(c.getText());
                }
                else {
                    if(!firstparam) sb.append(", ");
                    else firstparam = false;
                    sb.append(c.getName());
                    sb.append(" = 0");
                }
            }
            sb.append(", Judge1 = \""+JS_JudgeInitials1.getText()+"\"");
            sb.append(", Judge2 = \""+JS_JudgeInitials2.getText()+"\"");
            sb.append(" where entrant_num = ");
            sb.append(JS_EntrantNumber.getText());
        }
        // Execute the insert or update rqst constructed in the StringBuffer sb
        if(sb.length() > 0) {
            judgingSheetWait.setEnabled(true);
            judgingSheetWait.setVisible(true);
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(JudgeSheetSubPanel, sb.toString());
            waitForIt(judgingSheetWait);
            int j1total = 0;
            int j2total = 0;
            if (!JS_BodyScore1.getText().equals(""))  
                j1total += Integer.parseInt(JS_BodyScore1.getText());
            if (!JS_EngineScore1.getText().equals("")) 
                j1total += Integer.parseInt(JS_EngineScore1.getText());
            if (!JS_InteriorScore1.getText().equals(""))
                j1total += Integer.parseInt(JS_InteriorScore1.getText());
            if( !JS_ChassisScore1.getText().equals(""))
                j1total += Integer.parseInt(JS_ChassisScore1.getText());
            if(!JS_TireScore1.getText().equals(""))
                j1total += Integer.parseInt(JS_TireScore1.getText());
            if(!JS_WheelsScore1.getText().equals(""))
                j1total += Integer.parseInt(JS_WheelsScore1.getText());
            if(!JS_BodyScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_BodyScore2.getText());
            if(!JS_EngineScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_EngineScore2.getText());
            if(!JS_InteriorScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_InteriorScore2.getText());
            if(!JS_ChassisScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_ChassisScore2.getText());
            if(!JS_TireScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_TireScore2.getText());
            if(!JS_WheelsScore2.getText().equals(""))
                j2total += Integer.parseInt(JS_WheelsScore2.getText());
            if(debug) logger.log(Level.INFO,"JdgShtSaveActPerf: judge1 total:"+j1total);
            if(debug) logger.log(Level.INFO,"JdgShtSaveActPerf: judge2 total:"+j2total);
            String request = "update "+SQLiteCommandHandler.Scoring+" set j1_total = "+
                j1total+" , j2_total = "+j2total+" where entrant_num = "+
                EntNum;
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(JudgeSheetSubPanel, request);
            waitForIt(judgingSheetWait);
            //if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
            // Parse the awards checkboxes next, updating those verbatim
            // first see if any *are* checked & known to be valid by now
            // this will be zero if we never went through the routine
            // above (awardsChanged = false)
            if(boxesSeen > 0 || deleteCase) {
                int awardscnt = 0; //
                sb = new StringBuilder(); // Entrants update string
                StringBuilder specialsSb1 = new StringBuilder();
                StringBuilder specialsSb2 = null; // for 2 awards case
                if(SpecialAwards.size() > 0) { // deleteCase only applies in this block
                    Iterator citer = AwardsBoxes.iterator();
                    while(citer.hasNext()) {
                        JCheckBox c = (JCheckBox)citer.next();
                        if(c.isSelected()) {
                            if(boxesSeen == 1 || specialsSb1.length() == 0) {
                                if (SpecialAwards.containsKey(c.getName()))  {
                                     if(( SpecialAwards.get(c.getName()).equals(JS_EntrantNumber.getText())
                                       || SpecialAwards.get(c.getName()).equals(""))) {
                                         sb.append("update " + SQLiteCommandHandler.Entrants + " set aw1 = \"").append(c.getName()).append("\"");
                                         specialsSb1.append("update "+SQLiteCommandHandler.Specials
                                           +" set entrant_num = "+EntNum
                                           +" where award = \""+c.getName()+"\"");
                                         awardscnt++;
                                    }
                                }
                                else { // new entry case
                                    sb.append("update "+SQLiteCommandHandler.Entrants
                                      +" set aw1 = \""+c.getName()+"\"");
                                    specialsSb1.append("insert into "+SQLiteCommandHandler.Specials
                                      +" ( award , entrant_num ) values ( \""+c.getName()+"\" , "
                                      +EntNum+")");
                                    awardscnt++;
                                }
                            }
                            else  {// 2 boxes assumed...
                                if(SpecialAwards.containsKey(c.getName())) {
                                    if(SpecialAwards.get(c.getName()).equals(EntNum)) {
                                            sb.append(", aw2 = \"").append(c.getName()).append("\"");
                                            specialsSb2.append("update "+SQLiteCommandHandler.Specials
                                            +" set entrant_num = "+EntNum
                                            +" where Specials.award = \""+c.getName()+"\"");
                                    }
                                }
                                else {
                                    sb.append(", aw2 = \"").append(c.getName()).append("\"");
                                    specialsSb2 = new StringBuilder();
                                    specialsSb2.append("insert into "+SQLiteCommandHandler.Specials+
                                    " ( award, entrant_num ) values (\""+c.getName()+
                                    "\" , "+EntNum+")");
                                }
                            }
                        }
                        else { // Award remove from user case
                            if(SpecialAwards.containsKey(c.getName())) {
                                if(SpecialAwards.get(c.getName()).equals(EntNum)) {
                                    if(sb.length() == 0)
                                        sb.append("update "+SQLiteCommandHandler.Entrants);
                                    if(awardscnt == 0) {
                                        sb.append(" set aw1 = \"\"");
                                        awardscnt++;
                                    }
                                    else {
                                        if(sb.toString().contains("set"))
                                            sb.append(", aw2 = \"\"");
                                        else sb.append(" set aw2 = \"\"");
                                    }
                                    if(specialsSb1.length() == 0)
                                        specialsSb1.append("delete from "+SQLiteCommandHandler.Specials
                                          +" where award = \""+c.getName()+"\"");
                                    else {
                                        specialsSb2 = new StringBuilder();
                                        specialsSb2.append("delete from "+SQLiteCommandHandler.Specials+
                                        " where award = \""+c.getName()+"\"");
                                    }
                                }
                            }
                        }
                    }
                    if(sb.length() > 0) sb.append(" where entrant_num = "+EntNum);
                }
                else {  // no SpecialAwards yet...
                    specialsSb1.append("insert into "+SQLiteCommandHandler.Specials+
                        " (award, entrant_num) values ( ");
                    if(boxesSeen > 1) {
                        specialsSb2 = new StringBuilder();
                        specialsSb2.append("insert into "+SQLiteCommandHandler.Specials+
                            " (award, entrant_num) values ( ");
                    }
                    sb.append("update "+SQLiteCommandHandler.Entrants+" set ");
                    Iterator aiter = AwardsBoxes.iterator();
                    while(aiter.hasNext()) {
                        javax.swing.JCheckBox c = (javax.swing.JCheckBox)aiter.next();
                        if(c.isSelected()) { // here's one
                            if(awardscnt == 0)  {
                                sb.append("aw1 = \"");
                                awardscnt++;
                                specialsSb1.append("\""+c.getName()+"\", "+EntNum+")");
                            }
                            else {
                                sb.append(", aw2 = \"");
                                specialsSb2.append("\""+c.getName()+"\", "+EntNum+")");
                            }
                            sb.append(c.getName()+"\" ");
                        }
                    }
                    sb.append(" where entrant_num = "+EntNum);
                }
                if (sb.length() > 0) {
                    judgingSheetWait.setVisible(true);
                    if(taskStackStatus(false)) { taskStackStatus(true); }
                    sqlPut(specialtyAwardsLabel, sb.toString());
                    waitForIt(judgingSheetWait);
                    //if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
                }
                if(specialsSb1.length() > 0) {
                    if(debug) logger.log(Level.INFO,"JSSaveActPerf: handling specialsSb1: "+specialsSb1.toString());
                    judgingSheetWait.setVisible(true);
                    if(taskStackStatus(false)) { taskStackStatus(true); }
                    sqlPut(specialtyAwardsLabel, specialsSb1.toString());
                    waitForIt(judgingSheetWait);
                    //if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
                }
                if(specialsSb2 != null) {
                    if(debug) logger.log(Level.INFO,"JSSaveActPerf: handling specialsSb1: "+specialsSb1.toString());
                    judgingSheetWait.setVisible(true);
                    if(taskStackStatus(false)) { taskStackStatus(true); }
                    sqlPut(specialtyAwardsLabel, specialsSb2.toString());
                    waitForIt(judgingSheetWait);
                    //if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
                }
                if(specialsSb1.length() > 0 || specialsSb2 != null) {
                    if(debug) logger.log(Level.INFO,"JSSaveActPerf: call setSpecialAwards()");
                    setSpecialAwards();
                }
            }
 
            fiter = JudgingFields.iterator();
            while(fiter.hasNext()) {
                javax.swing.JTextField c = fiter.next();
                if(c.getText().equals("")) {
                    c.requestFocus();
                    break;
                }
            }            
        }
    }//GEN-LAST:event_JudgeSheetSaveActionPerformed

    /**
     * Detects the click into the EntrantNumber text field on the Registration
     * panel.  This implements the clear field on the Entrant number field
     * when you click into it.
     * @param evt 
     */
    private void EntNumMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_EntNumMouseClicked
        if(debug) logger.log(Level.INFO,"EntNumMouseClicked hit! Clear EntrantNumber");
        EntrantNumber.setText("");
    }//GEN-LAST:event_EntNumMouseClicked

    /**
     * Print action performed block to trigger the printing of the scoring
     * sheets on button click.
     * @param evt 
     */
    private void RegPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RegPrintActionPerformed
        if(debug) logger.log(Level.INFO,"RegPrtActPerf: printScoringSheets");
        printScoringSheets();
    }//GEN-LAST:event_RegPrintActionPerformed

    /**
     * This action performed block captures changes to any of the judging
     * award check boxes.  This is used in the save operation to determine if
     * we need to evaluate the check boxes for add/remove of named "special"
     * award.
     * @param evt 
     */
    private void JSBoxesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JSBoxesActionPerformed
        if(debug) logger.log(Level.INFO,"JSBoxesActPerf: "+evt.getActionCommand()+" box checked...");
        awardsChanged = true;
    }//GEN-LAST:event_JSBoxesActionPerformed

    /**
     * Toggle the debug flag.  When implemented, this will turn the debug
     * statements output off and on.
     * @param evt 
     */
    private void debugButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_debugButtonActionPerformed
        if(debug == true) {
            debug = false;
            SqlClientReader.setDebug(false);
            ((myJTabbedPane)tabbedPane).setDebug(false);
        }
        else {
            debug = true;
            SqlClientReader.setDebug(true);
            ((myJTabbedPane)tabbedPane).setDebug(true);
        }
    }//GEN-LAST:event_debugButtonActionPerformed

    /**
     * Handler for when the NewClassMnemonic field on the Classes Admin Panel
     * loses focus (somebody tabbed/clicked out of the field) which triggers
     * the search for an already used value of mnemonic.  If already used,
     * a pop-up will inform the user.
     * @param evt 
     */
    private void NewClassFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_NewClassFocusLost
        String s = NewClassMnemonic.getText();
        if(debug) logger.log(Level.INFO,"NewClassMnemonicFocusLost fired...");
        if(activeClasses != null) {
            for (int i = 0; i < activeClasses.length; i++) {
                // audit the classes and see if there is a preexisting class of this name
                if(activeClasses[i].equals(s)) {
                    JOptionPane.showMessageDialog(tabbedPane,
                      "Class label is already in use. Please choose a" +
                      " different label for this new class.",
                      "Class Data", JOptionPane.ERROR_MESSAGE);
                    NewClassMnemonic.setText("");
                    NewClassMnemonic.requestFocus();
                    return;
                }
            }
        }
    }//GEN-LAST:event_NewClassFocusLost
    /**
     * Clear the registration number field on the Judging Sheet panel when
     * the user clicks into that field on the form.
     * @param evt 
     */
    private void JS_RegNumFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JS_RegNumFocusGained
        JS_EntrantNumber.setText("");
        JS_SaveButton.setForeground(java.awt.Color.BLACK);
    }//GEN-LAST:event_JS_RegNumFocusGained

    private void SaveAdminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveAdminActionPerformed
        if(debug) logger.log(Level.INFO,"SaveAdminActPerf: event is "+evt.paramString());
        if(ShowDate.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
              "Show date is unset.",
              "Show Data", JOptionPane.ERROR_MESSAGE);
            ShowDate.requestFocus();
            return;
        }
        if(ContestName.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
              "Car show contest name is unset.",
              "Show Data", JOptionPane.ERROR_MESSAGE);
            ContestName.requestFocus();
            return;
        }
        // this will enforce location settings, we won't require it for
        // the beta release
        /*if(ShowLocation.getText().equals("")) {
            JOptionPane.showMessageDialog(tabbedPane,
              "Show location is unset.",
              "Show Data", JOptionPane.ERROR_MESSAGE);
            ShowLocation.requestFocus();
            return;
        } */
        StringBuffer sb = null;
        StringBuffer sb2 = null;
        boolean name_chg = false;
        boolean date_chg = false;
        ShowDate.setText(ShowDate.getText().replaceAll("~","").replaceAll("\"","").replaceAll(",",".").trim());
        String  parsedDate = ShowDate.getText().replace(", ", "~ ");
        String parsedName = ContestName.getText().replaceAll("\"","").replaceAll(",",".").trim();
        if(CurrentCarShowName != null && 
                !CurrentCarShowName.equals(ContestName.getText()) | CurrentCarShowName == null) 
            name_chg = true;
        if (!ShowDate.getText().equals(CarShowDate))
            date_chg = true;

        if((date_chg || name_chg) & CurrentCarShowName != null) {
                    sb = new StringBuffer();
                    sb2 = new StringBuffer();
                    sb.append("delete from "+SQLiteCommandHandler.ShowData+" where "+
                        "showname = \""+CurrentCarShowName+"\"");
                    CurrentCarShowName = null;
                    
                    sb2.append("insert into "+SQLiteCommandHandler.ShowData+
                        "(showname, showdate) values ( \""+parsedName+
                        "\" , \""+parsedDate+"\")");
        }
        else if(name_chg) { // name chgd & wasn't set before, insert
            sb = new StringBuffer();
            parsedDate = ShowDate.getText().replaceAll(", ",". ").
                replaceAll("\"","").trim();
            sb.append("insert into "+SQLiteCommandHandler.ShowData+
                " (showname, showdate) values ( \""+parsedName+
                "\", \""+parsedDate+"\")");
        }
        else if(date_chg) { // name didn't change, check date
            sb = new StringBuffer();
            //parsedDate = ShowDate.getText().replaceAll(", ",". ").replaceAll("\"","").trim();
            if(CarShowDate != null | CurrentCarShowName != null) {
                sb.append("delete from "+SQLiteCommandHandler.ShowData+
                    " where showname = \""+parsedName+"\"");
                sb2 = new StringBuffer();
                sb2.append("insert into "+SQLiteCommandHandler.ShowData+
                    " (showname, showdate) values ( \""+parsedName+
                    "\", \""+parsedDate+"\")");
            }
            else {
                sb.append("insert into "+SQLiteCommandHandler.ShowData+
                    " (showname, showdate) values (\""+ContestName.getText()+
                    "\", \""+parsedDate+"\")");
            }
        }
        if(sb != null) {
            if(debug) logger.log(Level.INFO,"admChgFocusLost: sending: "+sb.toString());
            AdminWait.setEnabled(true);
            AdminWait.setVisible(true);
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(AdminPanel, sb.toString());
            waitForIt(AdminWait);
        }
        if(sb2 != null) {
            if(debug) logger.log(Level.INFO,"admChgFocusLost: sending insert: "+sb.toString());
            AdminWait.setEnabled(true);
            AdminWait.setVisible(true);
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(AdminPanel, sb2.toString());
            waitForIt(AdminWait);        }
    }//GEN-LAST:event_SaveAdminActionPerformed

    private void EntrantDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EntrantDeleteActionPerformed
        if(EntrantNumber.getText().equals("")) {
            return;
        }
        else {
            if(evt.getActionCommand().equals("Confirm")) {
                EntrantDeleteButton.setText("Delete");
                EntrantDeleteButton.setForeground(java.awt.Color.GRAY);
                String oldEntrant = EntrantNumber.getText();
                String request = "delete from Entrants where entrant_num = "+
                    oldEntrant;
                regWait.setEnabled(true);
                regWait.setVisible(true);
                sqlPut(EntrantDeleteButton,request);
                waitForIt(regWait);
                request = "delete from "+SQLiteCommandHandler.Scoring+" where "+
                   "entrant_num = "+oldEntrant;
                regWait.setEnabled(true);
                regWait.setVisible(true);
                sqlPut(EntrantClear,request);
            }
            else {
                EntrantDeleteButton.setForeground(java.awt.Color.RED);
                EntrantDeleteButton.setText("Confirm");
                EntrantDeleteButton.requestFocus();
            }
        }
    }//GEN-LAST:event_EntrantDeleteActionPerformed

    /**
    * @param args no arguments are currently supported, future may support
     * selection of remote system name/ip-addr, database filename
    */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //Logger UILogger = new Logger("carshow.log");
                //java.util.logging.ConsoleHandler.formatter = java.util.logging.FileHandler;
                CarShowUI cs = new CarShowUI();
                
                cs.setVisible(true);
            }
        });
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddClassButton;
    private javax.swing.JButton AddEntrant;
    private javax.swing.JLabel AddrLabel;
    private javax.swing.JPanel AdminPanel;
    public java.awt.Label AdminWait;
    private javax.swing.JScrollPane AwardsPane;
    private javax.swing.JPanel AwardsPanel;
    private javax.swing.JButton AwardsPrintButton;
    private javax.swing.JButton AwardsSaveResultsButton;
    public java.awt.Label AwardsWait;
    private javax.swing.JCheckBox BestCustomBox;
    private javax.swing.JCheckBox BestInteriorBox;
    private javax.swing.JCheckBox BestPaintBox;
    private javax.swing.JCheckBox BestStreetRodBox;
    private javax.swing.JCheckBox BestTruckBox;
    private javax.swing.JLabel BodyMxPtsLabel1;
    private javax.swing.JLabel BodyMxPtsLabel2;
    private javax.swing.JLabel BodyScoreLabel1;
    private javax.swing.JLabel BodyScoreLabel2;
    private javax.swing.JTable CarScores;
    private javax.swing.JLabel ChassisMxPtsLabel1;
    private javax.swing.JLabel ChassisMxPtsLabel2;
    private javax.swing.JLabel ChassisScoreLabel1;
    private javax.swing.JLabel ChassisScoreLabel2;
    private javax.swing.JLabel CityLabel;
    private javax.swing.JLabel ClassLabel;
    private javax.swing.JLabel ClassLabel1;
    private javax.swing.JScrollPane ClassListPanel;
    public javax.swing.JTable ClassListTable;
    private javax.swing.JLabel ClassMnemonicLabel;
    private javax.swing.JLabel ClassNameLabel;
    private javax.swing.JPanel ClassSetPanel;
    public java.awt.Label ClassWait;
    private javax.swing.JLabel ColorLabel;
    private javax.swing.JTextField ContestName;
    private javax.swing.JLabel ContestNameLabel;
    private javax.swing.JButton DeleteClassButton;
    private javax.swing.JLabel EndYearLabel;
    private javax.swing.JLabel EngineMxPtsLabel1;
    private javax.swing.JLabel EngineMxPtsLabel2;
    private javax.swing.JLabel EngineScoreLabel1;
    private javax.swing.JLabel EngineScoreLabel2;
    private javax.swing.JTextField EntrantAddress;
    private javax.swing.JTextField EntrantCity;
    public javax.swing.JComboBox EntrantClass;
    private javax.swing.JButton EntrantClear;
    public javax.swing.JComboBox EntrantClub;
    private javax.swing.JTextField EntrantColor;
    private javax.swing.JButton EntrantDeleteButton;
    private javax.swing.JTextField EntrantMake;
    private javax.swing.JTextField EntrantModel;
    private javax.swing.JTextField EntrantNumber;
    private javax.swing.JTextField EntrantParking;
    private javax.swing.JTextField EntrantPhone;
    private javax.swing.JButton EntrantSearch;
    private javax.swing.JTextField EntrantState;
    private javax.swing.JTextField EntrantYear;
    private javax.swing.JTextField EntrantZipCode;
    private javax.swing.JLabel EntryNumLabel;
    private javax.swing.JLabel EntryNumLabel2;
    private javax.swing.JTextField FirstName;
    private javax.swing.JLabel FirstNameLabel;
    private javax.swing.JLabel HostClubName;
    private javax.swing.JLabel IPAddrLabel;
    private javax.swing.JLabel InteriorMxPtsLabel1;
    private javax.swing.JLabel InteriorMxPtsLabel2;
    private javax.swing.JLabel InteriorScoreLabel1;
    private javax.swing.JLabel InteriorScoreLabel2;
    private javax.swing.JLabel JSColorLabel;
    private javax.swing.JTextField JS_BodyScore1;
    private javax.swing.JTextField JS_BodyScore2;
    private javax.swing.JTextField JS_ChassisScore1;
    private javax.swing.JTextField JS_ChassisScore2;
    private javax.swing.JTextField JS_EngineScore1;
    private javax.swing.JTextField JS_EngineScore2;
    private javax.swing.JTextField JS_EntrantClass;
    private javax.swing.JTextField JS_EntrantColor;
    public javax.swing.JTextField JS_EntrantMake;
    public javax.swing.JTextField JS_EntrantModel;
    private javax.swing.JTextField JS_EntrantNumber;
    private javax.swing.JTextField JS_EntrantYear;
    private javax.swing.JTextField JS_InteriorScore1;
    private javax.swing.JTextField JS_InteriorScore2;
    private javax.swing.JTextField JS_JudgeInitials1;
    private javax.swing.JTextField JS_JudgeInitials2;
    private javax.swing.JLabel JS_ParkingNumLabel;
    public javax.swing.JTextField JS_ParkingNumber;
    private javax.swing.JButton JS_SaveButton;
    private javax.swing.JTextField JS_TireScore1;
    private javax.swing.JTextField JS_TireScore2;
    private javax.swing.JTextField JS_WheelsScore1;
    private javax.swing.JTextField JS_WheelsScore2;
    private javax.swing.JLabel JudgeInitialsLabel1;
    private javax.swing.JLabel JudgeIntialsLabel2;
    private javax.swing.JPanel JudgeSheetPanel;
    private javax.swing.JPanel JudgeSheetSubPanel;
    private javax.swing.JScrollPane JudgingPane;
    private javax.swing.JPanel JudgingPanel;
    public java.awt.Label JudgingWait;
    private javax.swing.JTextField LastName;
    private javax.swing.JLabel LastNameLabel;
    private javax.swing.JLabel MakeLabel;
    private javax.swing.JLabel MakeLabel1;
    private javax.swing.JLabel ModelLabel;
    private javax.swing.JLabel ModelLabel1;
    private javax.swing.JLabel ModelLabel2;
    private javax.swing.JTextField MostClubMembers;
    private javax.swing.JLabel MostClubsLabel;
    private javax.swing.JTextField NewClassEndYear;
    private javax.swing.JTextField NewClassMnemonic;
    private javax.swing.JTextField NewClassName;
    private javax.swing.JTextField NewClassStartYear;
    private javax.swing.JLabel ParkingNumLabel;
    private javax.swing.JCheckBox ParticipantChoiceBox;
    private javax.swing.JLabel PhoneLabel;
    private javax.swing.JCheckBox RebelsChoiceBox;
    private javax.swing.JButton RegPrint;
    private javax.swing.ButtonGroup RegStatusButtonGroup;
    public javax.swing.JPanel RegistrationPanel;
    private javax.swing.JTable ReportTable;
    private javax.swing.JTextField ScoringServerName;
    private javax.swing.JTextField SecondMostClub;
    private javax.swing.JLabel ServerNameLabel;
    private javax.swing.JTextField ShowDate;
    private javax.swing.JLabel ShowDateLabel;
    private javax.swing.JTextField ShowLocation;
    private javax.swing.JLabel ShowLocationLabel;
    private javax.swing.JLabel StartYearLabel;
    private javax.swing.JLabel StateLabel;
    private javax.swing.JLabel TiresMxPtsLabel1;
    private javax.swing.JLabel TiresMxPtsLabel2;
    private javax.swing.JLabel TiresScoreLabel1;
    private javax.swing.JLabel TiresScoreLabel2;
    private javax.swing.JLabel WheelsMxPtsLabel1;
    private javax.swing.JLabel WheelsMxPtsLabel2;
    private javax.swing.JLabel WheelsScoreLabel1;
    private javax.swing.JLabel WheelsScoreLabel2;
    private javax.swing.JLabel YearLabel;
    private javax.swing.JLabel YearLabel1;
    private javax.swing.JLabel ZipLabel;
    private javax.swing.JToggleButton debugButton;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    public java.awt.Label judgingSheetWait;
    public java.awt.Label regWait;
    private javax.swing.JLabel specialtyAwardsLabel;
    public javax.swing.JTabbedPane tabbedPane;
    private javax.swing.JPanel wrapperPanel;
    // End of variables declaration//GEN-END:variables


    /**
     * Schedule the judgingReport() method on a periodic (2 sec.) timer.
     * This give the refresh capability to the judging report panel and
     * allows tabbed panel changes to stop the timer when a different tab
     * has been selected.
     */
    private void schedReport() {
         
        //Report_scheduler
         
        rptPoll = true;
        rptActionListener = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                if(rptPoll)
                judgingReport();
            }
        };    
        rTimer = new javax.swing.Timer(2000, rptActionListener);
        rTimer.start();    
        if(debug) logger.log(Level.INFO,
            " judging panel timer started");
    }
    /**
     * judgingReport - cycles on a periodic viewing the judging records
     * It requests a multi-record SQL query (a set of CSV lines, one for each
     * entrant).  The reply path from the SQLClientReader service will come
     * through the setJudgePanel() method to populate the Judging panel.
     */
    
    private void judgingReport() {
        JudgingWait.setEnabled(true);
        JudgingWait.setVisible(true);
        String entRequest = "select Entrants.entrant_num, Entrants.mnemonic,"+
            " Entrants.fname, Entrants.lname, Entrants.year, Entrants.make, "+
            "Entrants.model, Scoring.Judge1, Scoring.j1_total, Scoring.Judge2,"+
            "Scoring.j2_total, Entrants.printed from Entrants join Scoring"+
            " where Scoring.entrant_num=Entrants.entrant_num"+
            " order by Scoring.Judge1 == \"\", Scoring.Judge2 == \"\","+
            "Scoring.j1_total, Scoring.j2_total desc";
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(JudgingPanel, entRequest);
        waitForIt(JudgingWait);
    }

    /**
     * Get the data from the DB for the Awards Report panel.
     */
    private void getAwardsReport() {
        // this gets the current club participation counts
        // chooses the top 2 clubs & their counts from the DB
        String request = "select club, count(*) as c from Entrants where"+
            " club!=\"\" group by club order by c desc, entrant_num asc limit 2";
        AwardsWait.setEnabled(true);
        AwardsWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(MostClubMembers,request);
        waitForIt(AwardsWait);
        
        /* THIS query gets a list ordered the way we want excepting the
         * awards exclusions.
         * 
         * select Entrants.entrant_num, Entrants.mnemonic, Entrants.fname, 
         * Entrants.lname, Entrants.year, Entrants.make, Entrants.model, 
         * Scoring.j1_total, Scoring.j2_total, Entrants.aw1, Entrants.aw2 
         * from Entrants natural join Scoring where Entrants.entrant_num=Scoring.entrant_num
         * order by Entrants.mnemonic, ((j1_total+j2_total)/2) desc;
         * 
         * If no query can be developed that will exclude these award holding
         * rows, the reply path will need to collect them and put them up into
         * the display in the correct place in the screens (which may be the
         * only way given the strange rules of the Participants Choice
         * award.
         * 
         * 4/29/12 - added columns color & class_desc to request for conformance with
         * changed requirement per DTO - wm
         * 4/29/12 changed query to enforce tie-breaking by registration number
         * order (lowest reg # wins ties) per DTO -wm
         */
        request = "select Entrants.entrant_num, Entrants.mnemonic, "+
            "JudgeClasses.classname, Entrants.fname, Entrants.lname, "+
            "Entrants.year, Entrants.color, Entrants.make, Entrants.model, "+
            "Scoring.j1_total, Scoring.j2_total, Entrants.aw1, Entrants.aw2 from "+
            SQLiteCommandHandler.Entrants+" join "+SQLiteCommandHandler.Scoring+
            " join "+SQLiteCommandHandler.JudgeClasses+
            " where Entrants.entrant_num = Scoring.entrant_num and "+
            "Entrants.mnemonic = JudgeClasses.mnemonic "+
            "order by Entrants.mnemonic asc, (Scoring.j1_total + Scoring.j2_total) desc,"+
            " Entrants.entrant_num asc";
        AwardsWait.setEnabled(true);
        AwardsWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(AwardsPanel,request);
        waitForIt(AwardsWait);
    }
    
    /**
     * set the values on the Awards Report panel of the UI.  This is the
     * reply path from SqlClientReader() when the Awards report is requested.
     */
    void setAwardsPanel(String[] args) {
        // save award winners for later handling in this array
        java.util.HashMap<String, String> awardMap = new java.util.HashMap();
        String[][] awardWinners = new String[7][8]; // 6 majors + participantsChoice
        String lastClassSeen = null;
        int winnersIdx = 0;
        if(debug) logger.log(Level.INFO,
            "setAwardsPanel: args cnt: "+args.length);
        if(args != null && args.length > 0) {
            if(args.length == 1 && !args[0].contains(",")) {
                if(debug) logger.log(Level.INFO,
                    "Ret code or not data SQL from Awards request: "+args[0]);
            }
            else { // typical return path with multiple rows to display
                javax.swing.table.DefaultTableModel dm = (javax.swing.table.DefaultTableModel)ReportTable.getModel();
                dm.getDataVector().removeAllElements();
                for(int i = 0; i < args.length; i++) {
                    String entry = args[i];
                    String[] vals = entry.split(",");
                    if(vals.length < 13) {
                        if(debug) logger.log(Level.INFO,"too few cols "+vals.length+" expanding...");
                        
                        String[] nvals = new String[13];
                        System.arraycopy(vals, 0, nvals, 0, vals.length);
                        for(int a = vals.length; a < nvals.length; a++)
                            nvals[a] = "";
                        vals = nvals;
                    }
                    if(lastClassSeen == null) lastClassSeen = vals[1];
                    else {
                        if(!lastClassSeen.equals(vals[1])) { // handle class separation
                            Object[] o = new Object[1];
                            dm.addRow(o);
                            lastClassSeen = vals[1];
                        }
                    }
                    // now repack into report table cols, concat 2&3, strip 10 & 11
                    String[] dvals = new String[8];
                    dvals[0] = vals[0]; // reg #
                    dvals[1] = vals[1]+" "+vals[2]; // class
                    dvals[2] = vals[3]+" "+vals[4]; // fname+lname
                    dvals[3] = vals[5]; // year
                    dvals[4] = vals[6]; // color
                    dvals[5] = vals[7]; // make
                    dvals[6] = vals[8]; // model
                    if(vals[9].equals("null") || vals[9].equals("")) {
                        vals[9] = "0";
                    }
                    if(vals[10].equals("null") || vals[10].equals("")) {
                        vals[10] = "0";
                    }
                    int score = (Integer.parseInt(vals[9]) + Integer.parseInt(vals[10]));
                    dvals[7] = new Integer(score).toString();
                    // now handle the awards winners, only participants choice
                    // will populate into awards groups in top of table
                    // other award winners get stashed, put at end of list
                    if(!vals[11].equals("") && !vals[11].equals("null")) {
                        // if ParticipantsChoice, display in order & save it
                        if(vals[11].equals("ParticipantChoiceBox")) {
                            dm.addRow(dvals);
                        } // corrupt data handler...
                        if(vals[11].matches("\\S+Box")) {
                            System.arraycopy(dvals,0,awardWinners[winnersIdx++],0, dvals.length);
                            awardMap.put(vals[0],vals[11]); 
                        }
                    }
                    else {
                        dm.addRow(dvals);
                    }
                    // fix dynamic column widths by col# in table for Class
                    // this selects the max of (current,new-row-class-text.length)
                    javax.swing.table.TableColumn tc = ReportTable.getColumnModel().getColumn(1);
                    tc.setPreferredWidth(java.lang.Math.max(tc.getWidth(),dvals[1].length()));
                    // adjust to ensure whole name fld displays
                    tc = ReportTable.getColumnModel().getColumn(2);
                    tc.setPreferredWidth(java.lang.Math.max(tc.getWidth(),dvals[2].length()));
                } // end for loop, now add the awardWinners rows...
                java.util.Vector<String> vect = new java.util.Vector();
                java.util.Vector<String> vect2 = new java.util.Vector();
                vect.add("Award");
                dm.addRow(vect);
                vect2.add("Winners");
                dm.addRow(vect2); // I tried reusing the vector & it didn't work
                for(int k = 0; k < winnersIdx; k++) {
                    if(awardWinners[k][0] != null) { // check if slot is used
                        // find the special award for this entrant
                        // since we've lost it after we parsed the raw sql data
                        // put the special award name into the entrant # field
                        if(awardMap.containsKey(awardWinners[k][0])) {
                            if(debug) logger.log(Level.INFO,"patching "+awardWinners[k][0]+
                                "with "+awardMap.get(awardWinners[k][0]));
                            awardWinners[k][0]=awardMap.get(awardWinners[k][0]).replaceAll("Box","");
                        }
                        dm.addRow(awardWinners[k]);
                    }
                }
                // finally add the club award winners
                if(!MostClubMembers.getText().equals("")) {
                    java.util.Vector<String> vect3 = new java.util.Vector();
                    java.util.Vector<String> vect3a = new java.util.Vector();
                    java.util.Vector<String> vect3b = new java.util.Vector();
                    vect3.add("Most");
                    vect3a.add("Represented");
                    vect3a.add(MostClubMembers.getText());
                    vect3b.add("Club");
                    dm.addRow(vect3);
                    dm.addRow(vect3a);
                    dm.addRow(vect3b);
                }
                if(!SecondMostClub.getText().equals("")) {
                    java.util.Vector<String> vect4 = new java.util.Vector();
                    java.util.Vector<String> vect4a = new java.util.Vector();
                    vect4.add("2nd Most");
                    vect4a.add("Represented");
                    vect4a.add(SecondMostClub.getText());
                    dm.addRow(vect4);
                    dm.addRow(vect4a);
                }
            }
        }
        else {
            // null reply for report, nothing we can display, or a future error condition?
            //if(debug) {
                logger.log(Level.INFO,
                    "setAwardPanel: empty/null report data set");
            //}
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(AwardsPanel);
        AwardsWait.setVisible(false);
    }

    /**
     * Reply path for the SQL query requesting club representation counts for
     * determining most represented club at the show.
     * @param args 
     */
    void setClubAward(String[] args) {
        if(args != null ) {
            if(args.length == 1) {
                if(args[0].contains(",")) {
                    String[] vals = args[0].split(",");
                    MostClubMembers.setText(vals[0]);
                }
                else {
                    if(debug) logger.log(Level.INFO,"setClubAward: update/insert ret: "+args[0]);
                }
            }
            else { // multiple clubs returned, find the highest 2 counters
                // This may be all superflourous because I'm asking for the
                // order to be by the count(*) on the club so it should give
                // the first 2 
                String Most = null;
                String Second = null;
                int mostSeen = 0;
                int secondSeen = 0;
                for(int i = 0; i < args.length; i++) {
                    String[] vals = args[i].split(",");
                    if(mostSeen == 0 ) {
                        mostSeen = Integer.parseInt(vals[1]);
                        Most = vals[0];
                        continue;
                    }
                    else if (Integer.parseInt(vals[1]) >= mostSeen) {
                        secondSeen = mostSeen;
                        Second = Most;
                        mostSeen = Integer.parseInt(vals[1]);
                        Most = vals[0];
                        continue;
                    }
                    if(secondSeen == 0 & mostSeen > 0) {
                        secondSeen = Integer.parseInt(vals[1]);
                        Second = vals[0];
                    }
                    else if(Integer.parseInt(vals[1]) > secondSeen) {
                        secondSeen = Integer.parseInt(vals[1]);
                        Second = vals[0];
                    }
                }
                if(mostSeen > 0 && Most != null)
                    MostClubMembers.setText(Most+" ("+mostSeen+")");
                if(secondSeen > 0 && Second != null)
                    SecondMostClub.setText(Second+" ("+secondSeen+")");
            }
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(MostClubMembers);
        AwardsWait.setVisible(false);
    }
    
    /**
     * initialize the list of car classes on the registration jPanel.  Called
     * each time we enter the Registration panel as well as during init when
     * we add the class list drop-down to the Registration panel.
     */
    private void initClassList() {
        // Do a sqlGet() spec'ing the EntrantClass as the destination
        // This script removes the existing class list, SqlClientReader() will
        // populate it with DB data using popRegClasses() method.
        //((myJTabbedPane)tabbedPane).setActiveComponent(EntrantClass);
        regWait.setEnabled(true);
        regWait.setVisible(true);
        EntrantClass.removeAllItems();  // clear the list to repopulate
        if(debug) logger.log(Level.INFO,"initClassList: get JudgeClasses list from DB");
        String request = "select * from "+SQLiteCommandHandler.JudgeClasses+";";
        if(debug) logger.log(Level.INFO,"initClassList: request: "+request);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(EntrantClass, request);
        waitForIt(regWait);
        if (regWait.isVisible()) {
            logger.log(Level.INFO,"initClassList: wait never ended");
            regWait.setVisible(false);  // indeterminate state resultant here...
        }
    }

/**
 * initialize the EntrantClub jComboBox on the Registration panel.
 * This gets called whenever the Entrant Admin jPanel is displayed.
 * This also gets called after we add this combobox to the panel during init.
 */
    private void initClubsList() {
        regWait.setEnabled(true);
        regWait.setVisible(true);
        if(debug) logger.log(Level.INFO,"initClubList: request clubs from DB");
        String request = "select * from Clubs order by club asc";
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(EntrantClub, request);
        waitForIt(regWait);
        if (regWait.isVisible()) logger.log(Level.INFO,"initClubList: wait never ended");
    }

    /**
     * Initialize the car classes jPanel (Class Administration Setup).
     */
    private void initClassTable() {
        String request = "select * from JudgeClasses order by mnemonic desc";
        ClassWait.setEnabled(true);
        ClassWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(ClassListTable, request);
        waitForIt(ClassWait);
        if(ClassWait.isVisible()) {
            logger.log(Level.INFO,"initClassTable: wait never ended");
            ClassWait.setVisible(false);
        }
    }

    /**
     * Print the paper for the show.  This includes 2 copies of the
     * judging sheets and 1 copy of the entrant display sheet that has
     * their entrant number printed on it.  The values used come from
     * the Registration panel and the Administration panel (for the date
     * string printed at the top.)
     */
    private void printScoringSheets() {
        // this next will get you current date, we are using the form
        // date data (Administration panel) So, make sure the client knows
        // that is the master value for printing dates on forms.
        Calendar cal = GregorianCalendar.getInstance();
        String calFormat = "MMM d, yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(calFormat);
        
        // the commented line in this constructor call would use the
        // current date instead of the date entered on the registration
        // panel, which is a user controllable value.  It is believed
        // by the the author (wdm) that this is the desired operation
        // because then sheets printed will reflect the date that the
        // conducting club wants displayed on the form, in their specific
        // format.
        // 4/29/12 format change to class display field, now with form
        // displaying a longer string we need to substring out the class
        // mnemonic from the front of that string
        JudgingSheet js = new JudgingSheet(ContestName.getText(), 
            //sdf.format(cal.getTime()), EntrantNumber.getText().trim(),
            ShowDate.getText(), EntrantNumber.getText().trim(),
            EntrantParking.getText().trim(), EntrantMake.getText().trim(),
            EntrantModel.getText().trim(), EntrantColor.getText().trim(),
            EntrantYear.getText().trim(),((String)EntrantClass.getSelectedItem()));
            // this would strip the text from the class, but we want it printed
            //.substring(0,((String)EntrantClass.getSelectedItem()).indexOf(" ")));
        js.initPrint();
        js.setSize(840,580);
        //java.awt.print.PageFormat pf = new java.awt.print.PageFormat();
        //pf.setOrientation(java.awt.print.PageFormat.LANDSCAPE);
        PrinterJob printJob = PrinterJob.getPrinterJob();
        printJob.setCopies(2);
        printJob.setPrintable(js);
        if(printJob.printDialog()) {
            try {
                printJob.print();
            }
            catch(PrinterException pe) {
                logger.log(Level.INFO,"Error printing: " + pe);
            }
        }
        if(!printJob.isCancelled() && js.getPrinted()) {
            setEntrantPrinted(EntrantNumber.getText());
        }
    }
    /**
     * sets the printed value in the Entrants table of the CarShow database to
     * indicate an entrant has been printed at least once.
     * @param ent the registration number that was printed
     */
    
    private void setEntrantPrinted(String ent) {
        if(ent != null && !ent.equals("")) {
            String request = "update "+SQLiteCommandHandler.Entrants+" set "+
                " printed = \"*\" where entrant_num = "+ent;
            regWait.setEnabled(true);
            regWait.setVisible(true);
            if(debug) logger.log(Level.INFO,"setEntPrinted: request: "+request);
            if(taskStackStatus(false)) { taskStackStatus(true); }
            sqlPut(RegPrint, request);
            waitForIt(regWait);
            if (regWait.isVisible()) { 
                logger.log(Level.INFO,"setEntPrinted: wait never ended");
                regWait.setVisible(false);
            }
            //else ThisEntrantPrinted = true; // this may be needed or desirable
        }
    }
    
    /**
     * Reply path from SqlClientReader on setEntrantPrint() request.  Used to
     * inform the UI if the print job actually was printed by the print
     * subsystem.
     * @param ret 
     */
    void updatePrintStatus(String ret) {
        if(ret == null) 
            if(debug) logger.log(Level.INFO,
                "updPrintStat: null ret - may indicate update failure");
        else {
            if (Integer.parseInt(ret) < 0) 
                if(debug) logger.log(Level.INFO,
                    "updPrintStat: neg ret - probably update failed");
            RegPrint.setForeground(oldPrintColor);
        }
        // if non-negative, DB success, should always be 1 returned
        if(ret.equals("1")) {
            RegPrint.setForeground(java.awt.Color.magenta);
            ThisEntrantPrinted=true;
            this.repaint();
        }
        else {
            RegPrint.setForeground(oldPrintColor);
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(RegPrint);
        regWait.setVisible(false);
        ThisEntrantPrinted=true;
    }
    
    /**
     * Reply path from SqlClientReader to populate the values on the
     * Registration jPanel.  The initiating routines that triggers this
     * are the AddEntrantActionPeformed() and EntrantNumberFocusLost() methods.
     * 
     * @param retEnts comma separated SQL result set
     */
    void setEntrant(String retEnts) {
        ThisEntrantPrinted=false; // set below set it true if it is so...
        if(retEnts != null) {
            // populate the form with the values in the EntrantData[] array
            // first check if > 1 returned, which is invalid...
            if(retEnts.length() > 0) {
                clearEntrant();
                String[] flds = retEnts.split(",");
                int totflds = flds.length;
                if(totflds > 0 && flds[0].length() > 0 ) EntrantNumber.setText(flds[0]);
                if(totflds > 1 && flds[1].length() > 0 ) FirstName.setText(flds[1]);
                if(totflds > 2 && flds[2].length() > 0 ) LastName.setText(flds[2]);
                if(totflds > 3 && flds[3].length() > 0 ) {
                    for(int i = 0; i < EntrantClass.getItemCount(); i++) {
                        String c = (String)EntrantClass.getItemAt(i);
                        if(c.equals("")) continue;
                        c = c.substring(0,c.indexOf(" "));
                        if(c.equals(flds[3])) {
                            EntrantClass.setSelectedIndex(i);
                            break;
                        }
                    }
                }
                if(totflds > 4 && flds[4].length() > 0 ) EntrantAddress.setText(flds[4]);
                if(totflds > 5 && flds[5].length() > 0 ) EntrantCity.setText(flds[5]);
                if(totflds > 6 && flds[6].length() > 0 ) EntrantState.setText(flds[6]);
                if(totflds > 7 && flds[7].length() > 0 ) EntrantZipCode.setText(flds[7]);
                if(totflds > 8 && flds[8].length() > 0 ) EntrantPhone.setText(flds[8]);
                if(totflds > 9 && flds[9].length() > 0 ) EntrantMake.setText(flds[9]);
                if(totflds > 10 && flds[10].length() > 0 ) EntrantModel.setText(flds[10]);
                if(totflds > 11 && flds[11].length() > 0 ) EntrantColor.setText(flds[11]);
                if(totflds > 12 && flds[12].length() > 0 ) EntrantYear.setText(flds[12]);
                if(totflds > 13 && flds[13].length() > 0 ) EntrantParking.setText(flds[13]);
                if(totflds > 14 && flds[14].length() > 0 ) EntrantClub.setSelectedItem(flds[14]);
                //if(totflds > 15 && flds[15].equals("1"))
                //    RegStatusButtonGroup.setSelected(PreRegButton.getModel(), true);
                //else RegStatusButtonGroup.setSelected(CheckInButton.getModel(), true);
                AddEntrant.setText("Change");
                if(!RegPrint.isVisible()) RegPrint.setVisible(true);
                oldPrintColor = RegPrint.getForeground();
                
                // change the RegPrint btn color if it has been printed
                // db flds[16] is either "*" or empty/null
                if(flds.length > 16 && flds[16] != null && 
                        !flds[16].equals("") && !flds[16].equals("null")) {
                    RegPrint.setForeground(java.awt.Color.magenta);
                    ThisEntrantPrinted=true;
                }
                else {
                    RegPrint.setForeground(oldPrintColor);
                }
                EntrantDeleteButton.setEnabled(true);
                EntrantDeleteButton.setForeground(java.awt.Color.BLACK);
            }
        }
        else { // Deleted/non-existent Entrant case lands here
            logger.log(Level.INFO, "setEnt recvd a null");
            clearEntrant();
            EntrantParking.requestFocus();
            if(!in_init) {
                AddEntrant.setText("Add Entrant");
                RegPrint.setVisible(false);
            }
            EntrantDeleteButton.setEnabled(false);
            /*regWait.setVisible(false);
            if(((myJTabbedPane)tabbedPane).getActiveComponent().getName().
                    equals(EntrantDeleteButton.getName())) {
                ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantDeleteButton);
            }
            else {
                ((myJTabbedPane)tabbedPane).clearActiveComponent(RegistrationPanel);
            }*/
        }
        if (!in_init) {
            Component c = ((myJTabbedPane)tabbedPane).getActiveComponent();
            if ( c != null && c.getName().equals(RegistrationPanel.getName())) {
                if(debug) logger.log(Level.INFO,
                    "setEntrant: clear RegPanel ActiveComponent");
                ((myJTabbedPane)tabbedPane).clearActiveComponent(RegistrationPanel);
            }
            else if (c != null && c.getName().equals(EntrantDeleteButton.getName())) {
                if(debug) logger.log(Level.INFO,
                    "setEntrant: clear EntDeleteBtn ActiveComponent");
                ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantDeleteButton);
            }
            else if (c != null && c.getName().equals(EntrantClear.getName())) {
                if(debug) logger.log(Level.INFO,
                    "setEntrant: clear EntrantClear ActiveComponent");
                ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantClear);
            }
            else {
                logger.log(Level.INFO,
                    "setEntrant: active component is null or unexpected");
                if(c == null) logger.log(Level.INFO,"act component is null");
                else {
                    logger.log(Level.INFO,"act component: "+c.getName());
                    ((myJTabbedPane)tabbedPane).clearActiveComponent(c);
                }
            }
            regWait.setVisible(false);
        }
    }

    /**
     * Reply path for SqlClientReader to update the entrant data on the
     * registration panel when an New Entrant is Added.  Modifications are
     * returned through setEntrant()
     */
    void updEntrant(String retEnts) {
        if(debug) logger.log(Level.INFO,
            "updEntrant: rcvd string: "+retEnts);
        if(retEnts.matches("[1-9]+")) {
            // Check if this is a new entrant's number
            if(AddEntrant.getText().equals("Add Entrant") && EntrantNumber.getText().equals(""))
                EntrantNumber.setText(retEnts.trim());
            // if not in Change mode on the form, make it change mode now
            if(!AddEntrant.getText().equals("Change")) AddEntrant.setText("Change");
            FirstName.requestFocus();
            if(((myJTabbedPane)tabbedPane).getActiveComponent() != null) {
                if(debug) logger.log(Level.INFO,
                    "updEntrant2: disable ActiveComponent");
                ((myJTabbedPane)tabbedPane).clearActiveComponent(RegistrationPanel);
            }
        }
        in_update = false; // update done
        regWait.setVisible(false);
        EntrantDeleteButton.setEnabled(true);
    }
    
    /**
     * return path for multiple entrant return data from a entrant search
     * on the registration panel.  To fully appreciate the difference between
     * the setEntrant() and setMultiEntrant() methods, setMultiEntrant must
     * launch a selector pane that the user can select the desired entrant
     * from, which then must populate the main Registration panel with the
     * chosen entrant.
     * @param sqlData 
     */
    void setMultiEntrant(String[] sqlData) {
        EntrantSearchResults esr = null;
        if(sqlData.length > 0) {
            esr = new EntrantSearchResults();

            // a typical search results set line that would come in sqlData
            // 5,Tom,Tate,PRE,3409 Holland Dr,Yalte,WI,23232,111-222-3333,Ford,Truck,Black,1937,,,1
            for(int i = 0; i < sqlData.length; i++) {

                String entry = sqlData[i];
                String[] vals = entry.split(",");
                if(vals.length < 19) {
                    String[] nvals = new String[19];
                    System.arraycopy(vals, 0, nvals, 0, vals.length);
                    if(vals.length == 17) nvals[17] = "";
                    nvals[18] = "";
                    vals = nvals;
                }
                if(i < esr.resultTable.getRowCount()) {
                    ((EntrantSelectTableModel)esr.resultTable.getModel()).removeRow(i);
                    ((EntrantSelectTableModel)esr.resultTable.getModel()).insertRow(i, vals);
                }
                else
                    ((EntrantSelectTableModel)esr.resultTable.getModel()).addRow(vals);
            }
            // put the popup in the middle of the screen
            Dimension uidim = ((CarShowUI)this).getSize();
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            
            int w = esr.getSize().width;
            int h = esr.getSize().height;
            int x = (dim.width-w)/2;
            int y = (dim.height-h)/2;
            esr.setLocation(x, y);
            //int rowcnt = esr.resultTable.getRowCount();
            //int tblsize = esr.resultTable.getHeight();
            //int btnsize = esr.selButton.getHeight();
            //int newheight = tblsize + btnsize + 5;
            //esr.setSize(700,300);
            esr.scaleTable();
            esr.setEnabled(true);
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(RegistrationPanel);
        regWait.setVisible(false);
        if(esr != null) {
            esr.setVisible(true);
            esr.requestFocus();
            esr.setAlwaysOnTop(true);
        }
    }
    /**
     * Clears the contents of the registration panel
     */
    void clearEntrant() {
        if(debug) logger.log(Level.INFO,"clearEntrant: ***DELETING REGISTRATION FORM DATA***");
        if(!this.isVisible())
            return;
        EntrantNumber.setText("");
        FirstName.setText("");
        LastName.setText("");
        EntrantClass.setSelectedItem("");
        EntrantAddress.setText("");
        EntrantCity.setText("");
        EntrantState.setText("");
        EntrantZipCode.setText("");
        EntrantPhone.setText("");
        EntrantMake.setText("");
        EntrantModel.setText("");
        EntrantColor.setText("");
        EntrantYear.setText("");
        EntrantParking.setText("");
        boolean skip = false;
        if(EntrantClub.getItemCount() > 0 && !EntrantClub.getSelectedItem().equals("")) {
            if(activeClubs.length > 0) {
                for(int i = 0; i < activeClubs.length; i++) {
                    if (activeClubs[i].equals(EntrantClub.getSelectedItem()))
                        skip = true;
                }
                if(!skip) {
                    String[] nactive = new String[activeClubs.length+1];
                    System.arraycopy(activeClubs, 0, nactive, 0, activeClubs.length);
                    nactive[activeClubs.length] = (String)EntrantClub.getSelectedItem();
                    activeClubs = nactive;
                }
                // add any new clubs in activeClubs to the EntrantClub dropdown
                if(EntrantClub.getItemCount() < activeClubs.length) {
                    for(int k = EntrantClub.getItemCount(); k < activeClubs.length; k++)
                        EntrantClub.addItem(activeClubs[k]);
                }
            }
        }
        EntrantClub.setSelectedItem("");
        // This next block prefers the PRE class as default, if it exists
        // without this, Class dropdown defaults to current display value
/*        if(EntrantClass.getItemCount() > 0)
            for(int k = 0; k < EntrantClass.getItemCount(); k++) {
                if(EntrantClass.getItemAt(k).equals("PRE")) {
                    EntrantClass.setSelectedItem("PRE");
                    break;
                }
            } */
        ThisEntrantPrinted = false;
        RegPrint.setForeground(oldPrintColor);
        RegPrint.setVisible(false);
        AddEntrant.setText("Add Entrant");
        EntrantDeleteButton.setText("Delete");
        EntrantDeleteButton.setEnabled(false);
        focusSearch = false;
        in_update = false; // reset update/add state flag to add
    }
    
    /**
     * set the list judging classes on the Registration Panel.  This
     * is the callback from the SqlClientReader() to populate the classes selector.
     * @param classes array of class data objects to display in the field.
     */
    void setRegClasses(String[] classes) {
        if(activeClasses == null) {
            activeClasses = new String[classes.length];
        }
        else {
            if (classes.length > activeClasses.length) {
                activeClasses = new String[classes.length];
            }
        }
        boolean[] foundClasses = new boolean[classes.length];
        if(classes.length > 0) {
            int curr_count = EntrantClass.getItemCount();
            for (int i = 0; i < classes.length; i++) {
                if (classes[i] == null || classes[i].equals(""))
                    continue;
                String[] flds = classes[i].split(",");
                for (int k = 0; k < curr_count; k++) {
                    if (EntrantClass.getComponent(k).toString().equals(flds[0]))
                        foundClasses[i]=true;
                }
            }
            for(int i = 0; i < classes.length; i++) {
                if(classes[i] == null || classes[i].equals(""))
                    continue;
                String[] flds = classes[i].split(",");
                activeClasses[i] = flds[0];
                if(!foundClasses[i])
                    EntrantClass.addItem(flds[0]+" "+flds[1]);
            }
        }
        // provide a blank element in the list for searching
        if(EntrantClass.getItemCount() == classes.length)
            //EntrantClass.addItem("");
            EntrantClass.insertItemAt("",0);
        ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantClass);
        regWait.setVisible(false); // end RegistrationPanel.EntrantClass field update
    }
    /**
     * set the Registration JPanel object's Clubs list dropdown field on
     * Reg panel entry and when a new club has been added by a new Entrant
     * action/event.
     * @param _clubs string array of the clubs found in the DB and returned
     * by CarShow.SqlClientReader class.
     */
    void setRegClubs(String[] _clubs) {
        if(_clubs == null || _clubs.length == 0) { // strange condition we dont expect
            logger.log(Level.INFO, "setRegClubs: null or 0 len Clubs operation reply",
                (_clubs == null) ? "Null" : "Zero");
        }
        else if(_clubs.length == 1 && _clubs[0].matches("[-]*[0-9]+")) {
            if(debug) logger.log(Level.INFO, "detected numeric (retcode) in setRegClubs request");
            int ret = Integer.parseInt(_clubs[0]);
            if(ret > 0 & !EntrantClub.getSelectedItem().equals("")) { // successful DB update of a club add it to our internal table
                if(activeClubs == null) {
                    activeClubs = new String[1];
                    activeClubs[0] = (String)EntrantClub.getSelectedItem();
                }
                else {
                    String[] nact = new String[activeClubs.length+1];
                    System.arraycopy(activeClubs, 0, nact, 0, activeClubs.length);
                    nact[activeClubs.length] = (String)EntrantClub.getSelectedItem();
                    activeClubs = nact;
                }
            }
        }
        else { // SQL data response
            if(debug) logger.log(Level.INFO,
                "setRegClubs: num recd: "+_clubs.length);
            if (activeClubs == null) {
                activeClubs = new String[_clubs.length];
            }
            else {
                if (_clubs.length > activeClubs.length)
                    activeClubs = new String[_clubs.length];
            }
            boolean[] foundClubs = new boolean[_clubs.length];
            if(_clubs.length > 0) {
                int curr_count = EntrantClub.getItemCount();
                for (int i = 0; i < _clubs.length; i++) {
                    for (int k = 0; k < curr_count; k++) {
                        if(EntrantClub.getItemAt(k).equals(_clubs[i]))
                            foundClubs[i] = true;
                    }
                }
                for (int i = 0; i < _clubs.length; i++) {
                    activeClubs[i] = _clubs[i];
                    if(!foundClubs[i])
                        EntrantClub.addItem(_clubs[i]);
                }
            }
            EntrantClub.setSelectedItem("");
        }
        if(debug) logger.log(Level.INFO,
            "setRegClubs: clear ActiveComponent");
        ((myJTabbedPane)tabbedPane).clearActiveComponent(EntrantClub);
        regWait.setVisible(false);
        repaint();
    }
    /*******************************************************************/
    /** Set the list of classes on the Car Class Admin panel.
     * This is the reply method used by the SqlClientReader to
     * populate the screen with SQL data from the DB.
     */

    void setClassList(String[] cldata) {
        if(cldata == null) { // if the class table data was null (empty class table or error)
            ClassListTable.setBackground(java.awt.Color.YELLOW);
        }
        else if(cldata.length == 1 && !cldata[0].contains(",")) {
            if(debug && cldata[0].equals("1")) {
                logger.log(Level.INFO,
                    "setClassList: delete/add op succeeded");
            }
            else if (Integer.parseInt(cldata[0]) < 0) {
                logger.log(Level.SEVERE,
                    "setClassList: error ret: "+cldata[0]);
            }
            else {
                if(debug) logger.log(Level.WARNING,"setClassList: ret code: "+cldata[0]);
            }
        }
        else {
            boolean update = false;
            String[] oldActClasses = null;
            int cldatsize = cldata.length; // # of class records from table
            if (activeClasses == null){
                activeClasses = new String[cldatsize];
                update = true;
            }
            else if (!(cldatsize == activeClasses.length) )
            {
                update = true;
                oldActClasses = activeClasses;
                activeClasses = new String[cldatsize];
                clearClassList();
            }

            for(int i = 0; i < cldatsize; i++) {
                if(cldata[i].equals("null") || cldata[i].equals("") || !cldata[i].contains(",")) {
                    if(debug) logger.log(Level.INFO,"setClassList: null element"+
                        " or non SQL data in class list, element: "+i);
                    continue;
                }
                String[] vals = cldata[i].split(",");
                if(update) {
                    activeClasses[i] = vals[0];
                }
                if(i < ClassListTable.getRowCount()) {
                    ((javax.swing.table.DefaultTableModel)
                        ClassListTable.getModel()).removeRow(i);
                    ((javax.swing.table.DefaultTableModel)
                        ClassListTable.getModel()).insertRow(i, vals);
                }
                else {
                    ((javax.swing.table.DefaultTableModel)
                        ClassListTable.getModel()).addRow(vals);
            
                }
            }
            // clean up the classes table on delete, remove empty rows
            if(oldActClasses != null && oldActClasses.length > cldatsize) {
                // removed a class so remove empty rows from ClassListTable
                for(int i = 0; i < ClassListTable.getRowCount(); i++) {
                    if(ClassListTable.getValueAt(i, 0).equals("")) {
                        ((javax.swing.table.DefaultTableModel)
                            ClassListTable.getModel()).removeRow(i);
                    }
                }
            }
        }
        if(debug) logger.log(Level.INFO,"setClassList: setting class table white");
        ClassListTable.setBackground(java.awt.Color.WHITE);
        ((myJTabbedPane)tabbedPane).clearActiveComponent(ClassListTable);
        ClassWait.setVisible(false);
        clearClassForm();
        repaint();

    }
    /**
     * Set the entrant data on the Judging Sheet form.
     * @param sqlData the sql data to use in populating the form
     * Called by SqlClientReader to fill in the entrant data on the judging
     * sheet tab/pane/panel.
     */
    
    void setJudgingEntrant(String[] sqlData) {
        newScoreEntry = false;
        String[] vals = null;
        if(sqlData != null && sqlData.length > 0) {
            if(debug) logger.log(Level.INFO,"setJudgingEntrant: sqlData size:"+sqlData.length);
            if(sqlData.length > 1) 
                logger.log(Level.INFO,"setJudgingEnt: too many rows returned!");
            vals = sqlData[0].split(",");
            // correct if two awards values are empty/null
            if(vals.length != 9) { // # of cols requests
                if(debug) logger.log(Level.INFO,"setJudgingEnt: too few columns returned:"+vals.length);
                String[] tvals = new String[9];
                System.arraycopy(vals, 0, tvals, 0, vals.length);
                for(int k = vals.length; k < tvals.length; k++)
                    tvals[k] = "";
                vals = tvals;
            }
            if (vals != null && vals.length > 0) {
                // order of ret vals[]:
                // ent_num, make, model, parking, color, year, class
                JS_EntrantNumber.setText(vals[0].trim());
                JS_EntrantMake.setText(vals[1].trim());
                JS_EntrantModel.setText(vals[2].trim());
                JS_ParkingNumber.setText(vals[3].trim());
                JS_EntrantColor.setText(vals[4].trim());
                JS_EntrantYear.setText(vals[5].trim());
                JS_EntrantClass.setText(vals[6].trim());
                if(vals[7] != null && !vals[7].equals("")) {
                    Iterator iter = AwardsBoxes.iterator();
                    while(iter.hasNext()) {
                        JCheckBox c = (JCheckBox)iter.next();
                        if(c.getName().equals(vals[7])) {
                            c.setSelected(true);
                        }
                    }
                }
                // this handles the corner case where an entry has won 2 awards
                if(vals[8] != null && !vals[8].equals("") && vals[8].equals("ParticipantChoiceBox")) {
                   ParticipantChoiceBox.setSelected(true); 
                }
                JS_BodyScore1.requestFocus();
            }
        }
        else {
            if(debug) logger.log(Level.INFO,"setJudgingEnt: null/empty sqlData returned");
            clearJudgingSheet((byte)7); // clear whole form on null entrant data get
            JS_EntrantNumber.requestFocus();
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(JudgeSheetPanel);
        judgingSheetWait.setVisible(false);
        repaint();
    }

    /**
     * Set the data for the scoring update on the Judging Sheet tab.  This
     * is a reply path from SqlClientReader() to populate the Judging Panel
     * with judging scores from the Scoring table.
     * @param sqlData the array of the scores for the requested entrant
     */
    void setJudgingData(String[] sqlData) {
        String vals[] = null;
        if(sqlData != null && sqlData.length > 0) { // partial or full results
            if(sqlData.length > 1)
                if(debug) logger.log(Level.INFO,"setJudgingData: too many rows returned: "+sqlData.length);
            if(!sqlData[0].contains(",") && checkNum(sqlData[0].trim())) {
                // handle update ret code from DB, insert & update both
                logger.log(Level.INFO,"setJudDat: ret val rcvd: "+sqlData[0]);
                int ret = new Integer(sqlData[0]).intValue();
                if(ret == 1) {
                    if(debug) logger.log(Level.INFO,"setJudgingData: return code recvd");
                    newScoreEntry = false;
                    judgingSheetWait.setVisible(false);
                    ((myJTabbedPane)tabbedPane).clearActiveComponent(JudgeSheetSubPanel);
                    JS_SaveButton.setForeground(java.awt.Color.RED);
                    if(debug) System.out.println("Judging data update success");
                }
                else {
                    logger.log(Level.ALL,"setJudgingData: ret code: "+ret);
                }
            }
            else { // SQL Get results in CSV form returned from DB populate form
                vals = sqlData[0].split(",");
                if(vals.length != 17) { // fix too few rows
                    if(debug) logger.log(Level.INFO,"setJudgingData: wrong # of cols: "+vals.length);
                    String[] nvals = new String[17];
                    System.arraycopy(vals, 0, nvals, 0, vals.length);
                    for(int i = vals.length; i < nvals.length; i++)
                        nvals[i] = "";
                    vals = nvals;
                }
                else if(vals != null && vals.length > 0) {
                    // populate scoring data from result set
                    if(JS_EntrantNumber.getText().equals(vals[0])) {
                        if(!vals[1].trim().equals("null")) 
                            JS_JudgeInitials1.setText(vals[1].trim());
                        if(!vals[2].trim().equals("null")) JS_JudgeInitials2.setText(vals[2].trim());
                        if(!vals[3].trim().equals("null")) JS_BodyScore1.setText(vals[3].trim());
                        if(!vals[4].trim().equals("null")) JS_EngineScore1.setText(vals[4].trim());
                        if(!vals[5].trim().equals("null")) JS_InteriorScore1.setText(vals[5].trim());
                        if(!vals[6].trim().equals("null")) JS_ChassisScore1.setText(vals[6].trim());
                        if(!vals[7].trim().equals("null")) JS_TireScore1.setText(vals[7].trim());
                        if(!vals[8].trim().equals("null")) JS_WheelsScore1.setText(vals[8].trim());
                        // vals[9] = judge#1 total
                        if(!vals[10].trim().equals("null")) JS_BodyScore2.setText(vals[10].trim());
                        if(!vals[11].trim().equals("null")) JS_EngineScore2.setText(vals[11].trim());
                        if(!vals[12].trim().equals("null")) JS_InteriorScore2.setText(vals[12].trim());
                        if(!vals[13].trim().equals("null")) JS_ChassisScore2.setText(vals[13].trim());
                        if(!vals[14].trim().equals("null")) JS_TireScore2.setText(vals[14].trim());
                        if(!vals[15].trim().equals("null")) JS_WheelsScore2.setText(vals[15].trim());
                        // vals[16] = judge#2 total
                        Iterator<javax.swing.JTextField> fiter = JudgingFields.iterator();
                        int fcnt = 0;
                        while(fiter.hasNext()) {
                            javax.swing.JTextField c = fiter.next();
                            if(c.getText().equals("0")) {
                                if (fcnt > 5 && JS_JudgeInitials2.getText().equals("") ||
                                    fcnt < 6 && JS_JudgeInitials1.getText().equals(""))
                                        c.setText("");
                            }
                            fcnt++;
                        }
                    }
                    else
                        logger.log(Level.INFO,"setJudgingData: Data for wrong entrant returned!!!");
                }
                newScoreEntry = false;
            }
        }
        else { // null || zero-length sqlData
            newScoreEntry = true; // Score DB was empty - guranteed
            // null sqlData == empty set/ no data for this entrant in Scoring
            // check if the entrant data get was also empty (bad entrant# case)
            if(JS_EntrantNumber.equals("")) {
                clearJudgingSheet((byte)7);
                JS_EntrantNumber.requestFocus();
                currentJudgingEntrant = null;
            }
            else {
                currentJudgingEntrant = JS_EntrantNumber.getText();
                JS_BodyScore1.requestFocus();
            }
            JS_SaveButton.setForeground(java.awt.Color.BLACK);
        }
        awardsChanged = false;
        if(JS_EntrantNumber.getText().equals(""))
            JS_EntrantNumber.requestFocus();
        ((myJTabbedPane)tabbedPane).clearActiveComponent(JudgeSheetSubPanel);
        judgingSheetWait.setVisible(false);
        repaint();
    }
    
    /**
     * Reply path for SqlClientReader involving the JudgingPanel where the
     * status of all entrants judging is viewed on a periodic timer.
     * @param sqlData strings array containing the judging data from the DB.
     */
        void setJudgePanel(String[] sqlData) {
        String[] vals;
        //int rowidx = 0;
        javax.swing.table.DefaultTableModel dm = (javax.swing.table.DefaultTableModel)CarScores.getModel();
        dm.getDataVector().removeAllElements();
        if(sqlData == null) {
            if(debug) logger.log(Level.INFO,"setJudgePanel: sql data null");
        }
        else if (sqlData.length == 1 && !sqlData[0].contains(",")) {
                if(debug) logger.log(Level.INFO,"setJudgePanel: ret code recvd: "+sqlData[0]);
        }
        else {
            for(int i = 0; i < sqlData.length; i++) {
                vals = sqlData[i].split(",");
                if(vals.length != 12) {
                    String[] nvals = new String[12];
                    System.arraycopy(vals,0,nvals,0,vals.length);
                    for(int k = 0; k < nvals.length; k++)
                        nvals[k] = "";
                    vals = nvals;
                }
                if(vals.length == 12) {
                    // correct vals case
                    int colidx = 0;
                    String[] mvals = new String[9];
                    mvals[0] = vals[0]; // reg num
                    mvals[1] = vals[1]; // class
                    mvals[2] = vals[2]+" "+vals[3]; //fname lname
                    mvals[3] = vals[4]+" "+vals[5]+" "+vals[6]; // year make model
                    mvals[4] = vals[7]; // judge 1
                    mvals[5] = vals[8]; // score 1
                    mvals[6] = vals[9]; // judge2
                    mvals[7] = vals[10]; // score2
                    if(vals[11].equals("null"))
                        mvals[8] = "";
                    else mvals[8] = vals[11]; // printed
                    ((javax.swing.table.DefaultTableModel)CarScores.getModel()).addRow(mvals);
                } 
                else {
                    logger.log(Level.INFO,"setJudgePanel: wrong # cols: "+vals.length);
                    logger.log(Level.INFO,"setJudgePanel: rcvd sqlData[0]: "+sqlData[0]);
                } 
            } 
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(JudgingPanel);
        JudgingWait.setVisible(false);
        repaint();
    }
    
    /**
     * Clears the Classes Setup Panel ClassListTable contents.
     */
    private void clearClassList() {
        int nrows = ClassListTable.getRowCount();
        int ncols = ClassListTable.getColumnCount();
        for (int i = 0; i < nrows; i++) {
            for (int j = 0; j < ncols; j++)
                ClassListTable.setValueAt("", i, j);
        }
        resetClassTable();
    }
    

    /**
     * Clear the Class Setup panel input fields.
     */
    private void clearClassForm() {
        NewClassMnemonic.setText("");
        NewClassName.setText("");
        NewClassStartYear.setText("");
        NewClassEndYear.setText("");
    }

    /**
     * Wrapper of the class table initializer used by SqlClientReader object
     * as well as within the UI class to clear the Class Setup panel.
     * 
     */
     void resetClassTable() {
         // TODO: these two operations may not be required in latest design...
         ((myJTabbedPane)tabbedPane).clearActiveComponent(ClassListTable);
         ClassWait.setVisible(false);
         initClassTable();
     }

     /**
      * Clear the Judging Sheet panel form input fields.
      * @param segment defines the segment to erase in a bit-wise scheme
      * where 0x1 = clears entrant data
      *       0x2 = clears judge #1 data
      *       0x4 = clears judge #2 data
      *       0x7 = clear entrant, judge #1, judge #2 data
      */
    private void clearJudgingSheet(byte segment) {
        if((segment & 0x01) == 0x01) {
            JS_EntrantNumber.setText("");
            JS_ParkingNumber.setText("");
            JS_EntrantMake.setText("");
            JS_EntrantModel.setText("");
            JS_EntrantYear.setText("");
            JS_EntrantColor.setText("");
            JS_EntrantClass.setText("");
           if(AwardsBoxes != null) {
               Iterator iter = AwardsBoxes.iterator();
               while(iter.hasNext()) {
                   ((JCheckBox)iter.next()).setSelected(false);
               }
           }
           newScoreEntry = true;
        }
        if((segment & 0x02) == 0x02) {
            // judge #1 data clears when segment > 0
            JS_BodyScore1.setText("");
            JS_EngineScore1.setText("");
            JS_InteriorScore1.setText("");
            JS_ChassisScore1.setText("");
            JS_TireScore1.setText("");
            JS_WheelsScore1.setText("");
            JS_JudgeInitials1.setText("");
        }
        if((segment & 0x04) == 0x04) {
        //if(segment > 1) {
            // judge #2 data clears when segment > 1
            JS_BodyScore2.setText("");
            JS_EngineScore2.setText("");
            JS_InteriorScore2.setText("");
            JS_ChassisScore2.setText("");
            JS_TireScore2.setText("");
            JS_WheelsScore2.setText("");
            JS_JudgeInitials2.setText("");
        }
        repaint();
    }
    
    /**
     * This asks for the SpecialAwards hashMap to be populated from the DB.
     * This information will guide the parsing of the entered data on the
     * Judging Sheet panel, while this is clunky, it does afford us the ability
     * to poll this information immediately before we would apply an award to
     * a user, thus minimizing a race conditions that exists by the network
     * architecture.
     */
    private void setSpecialAwards() {
        if(SpecialAwards == null) SpecialAwards = new java.util.HashMap<String,String>();
        String request = "select * from Specials";
        judgingSheetWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(specialtyAwardsLabel, request);
        waitForIt(judgingSheetWait);
            if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
            else JS_SaveButton.setForeground(java.awt.Color.BLACK);
    }
    /**
     * Here is the reply path from SqlClientReader when a setSpecialAwards()
     * request is made.  A copy of the awarded "Special Awards" is kept on
     * the client and referred to when an attempt is made to assign an
     * award to a particular entrant.  If the award already exists in this table
     * then we treat it as already awarded.  The race condition exists if two
     * clients have Judging Sheets active and one updates and another updates
     * without refreshing (tabbing away and back into) the Judging Sheet panel
     * thus requesting a current look at the Specials table data.
     */
    void updateSpecialAwards(String[] args) {
        if(args == null) {
            SpecialAwards.clear(); // DB is empty
        }
        else {
            if(args.length > 0 && args[0].contains(",")) {
                SpecialAwards.clear();
                for(int i = 0; i < args.length; i++) {
                    String[] vals = args[i].split(",");
                    SpecialAwards.put(vals[0].trim(), vals[1].trim());
                }
            }
            else if(args.length == 1) {
               // return code
                if(debug) logger.log(Level.INFO,"updSpecAwards: db ret code "+args[0]);          
            }
            else { // this should be the case if we delete all results?
               if(debug) logger.log(Level.INFO,"updSpecAwards: empty return, treat as empty Specials table");
               if(!SpecialAwards.isEmpty()) {
                   SpecialAwards.clear();
               }
            }
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(specialtyAwardsLabel);
        judgingSheetWait.setVisible(false);
        repaint();
        if(!failedWait) JS_SaveButton.setForeground(java.awt.Color.RED);
        else JS_SaveButton.setForeground(java.awt.Color.BLACK);
    }
    
    /**
     * This is the reply path for the save results button on the Awards Panel.
     * The Save button will change color once a save has been done.
     */
    void setAwardsSaveResult(String ret) {
        if(ret == null) {
            if(debug) logger.log(Level.INFO,"setAwardsSaveResult: null ret probably OK");
        }
        else {
            if(Integer.parseInt(ret) > 0) {
                if(debug) logger.log(Level.INFO,"DB save result "+ret);
            }
            else {
                if(debug) logger.log(Level.INFO,"DB save failed "+ret);
            }
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(ReportTable);
        AwardsWait.setVisible(false);
        AwardsSaveResultsButton.setForeground(java.awt.Color.RED);
    }
    
    /**
     * Reply path from ClientReader when Admin data is changed in the ShowData
     * table.  
     * @param ret 
     */
    void setContestResult(String ret) {
        if(debug) logger.log(Level.INFO,"setContestRes: input str = "+ret);
        if(ret != null && ret.length() > 0) {
            if(ret.contains(",")) { // table data for Admin panel
                String[] vals = ret.split(",");
                if(vals.length < 2) {
                    String[] nvals = new String[2];
                    System.arraycopy(vals, 0, nvals, 0, nvals.length);
                    nvals[1] = "";
                    vals = nvals;
                }
                vals[1] = vals[1].replaceAll("~ ",", ");
                ContestName.setText(vals[0]);
                CurrentCarShowName = vals[0];
                CarShowDate = vals[1];
                ShowDate.setText(vals[1]);
            }
            else { // ret code from update/delete
                if(Integer.parseInt(ret) == 0) {
                    // DB table for show name & date is empty reflect this
                    // on the forms
                    ContestName.setText("");
                    CurrentCarShowName = null;
                    ShowDate.setText("");
                }
                else if (Integer.parseInt(ret) >= 1) {
                    //ContestName.setText("");
                    CurrentCarShowName = ContestName.getText();
                    CarShowDate = ShowDate.getText();
                }
                if(Integer.parseInt(ret) < 0) {
                    logger.log(Level.SEVERE, "setContestResult: a DB operation failed");
                }
            }
        }
        ((myJTabbedPane)tabbedPane).clearActiveComponent(AdminPanel);
        AdminWait.setVisible(false);
        AdminWait.setEnabled(false);
    }
    
    private void clearLocalTables() {
        if(activeClasses != null) activeClasses = null;
        if(EntrantClass.getItemCount() > 0) {
            javax.swing.DefaultComboBoxModel cbm = 
                (javax.swing.DefaultComboBoxModel)EntrantClass.getModel();
            cbm.removeAllElements();
        }
        if(activeClubs != null) activeClubs = null;
        if(EntrantClub.getItemCount()>0) {
            javax.swing.DefaultComboBoxModel cbm = 
                (javax.swing.DefaultComboBoxModel)EntrantClub.getModel();
            cbm.removeAllElements();
        }
    }
    /**
     * This initializes a HashMap object mapping DB field names to CarShowUI
     * input fields (mostly JTextField but one is a JComboBox)  for performing
     * the search functionality.  Order is somewhat less important here because
     * we will evaluate if each is set non empty and use it to form the
     * query string sent.
     */
    private void setEntrantFieldsList() {
        EntrantFields = new java.util.HashMap<String, javax.swing.JComponent>();
        EntrantFields.put("entrant_num",EntrantNumber);
        EntrantFields.put("fname", FirstName);
        EntrantFields.put("lname", LastName);
        EntrantFields.put("mnemonic", EntrantClass);
        EntrantFields.put("club", EntrantClub);
        EntrantFields.put("address", EntrantAddress);
        EntrantFields.put("city", EntrantCity);
        EntrantFields.put("state", EntrantState);
        EntrantFields.put("phone", EntrantPhone);
        EntrantFields.put("parking_loc", EntrantParking);
        EntrantFields.put("year", EntrantYear);
        EntrantFields.put("make", EntrantMake);
        EntrantFields.put("model", EntrantModel);
        EntrantFields.put("color", EntrantColor);
    }

    /**
     * This initializes an ordered list of the judge scoring fields.  The
     * list is then used to inquire the contents of these fields in an
     * automated way.  This permits a concise yet robust algorithm in the
     * judging sheet panel entered data analysis.
     */
    private void setJudgeSheetList() {
        JudgingFields = new java.util.LinkedList();
        JudgingFields.add(JS_BodyScore1);
        JudgingFields.add(JS_EngineScore1);
        JudgingFields.add(JS_InteriorScore1);
        JudgingFields.add(JS_ChassisScore1);
        JudgingFields.add(JS_TireScore1);
        JudgingFields.add(JS_WheelsScore1);
        JudgingFields.add(JS_BodyScore2);
        JudgingFields.add(JS_EngineScore2);
        JudgingFields.add(JS_InteriorScore2);
        JudgingFields.add(JS_ChassisScore2);
        JudgingFields.add(JS_TireScore2);
        JudgingFields.add(JS_WheelsScore2);
    }
    
    /**
     * sets up the AwardsBoxes LinkList object so various parts of
     * the code can iterate over the award checkboxes of the Judging Sheet
     * panel where scores are entered.
     */
    private void setAwardsButtonList() {
        AwardsBoxes = new java.util.LinkedList<javax.swing.JCheckBox>();
        AwardsBoxes.add(BestCustomBox);
        AwardsBoxes.add(BestStreetRodBox);
        AwardsBoxes.add(BestTruckBox);
        AwardsBoxes.add(BestInteriorBox);
        AwardsBoxes.add(BestPaintBox);
        AwardsBoxes.add(RebelsChoiceBox);
        AwardsBoxes.add(ParticipantChoiceBox);
    }
    
    /**
     * Format the judging results table showing the show winners list.
     */
    
    private void formatJudgingTable() {
        javax.swing.table.DefaultTableCellRenderer centerRenderer = 
                new javax.swing.table.DefaultTableCellRenderer();
        centerRenderer.setHorizontalAlignment( javax.swing.JLabel.CENTER );
        javax.swing.table.TableColumn column = null;
        for (int i = 0; i < CarScores.getColumnModel().getColumnCount(); i++) {
            column = CarScores.getColumnModel().getColumn(i);
            if (i == 0) {// registration # - narrow
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(70);

            }
            else if (i == 1) { // class mnemonic field - narrow
                column.setMaxWidth(50);
            }
            else if (i == 2) { // owner name - wide, variable
                column.setPreferredWidth(100);
            }
            else if (i == 3) { // vehicle - middling variable
                column.setPreferredWidth(120);
            }
            else if (i == 4 || i == 6) { // judge inits
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(70);
            }
            else if (i == 5 || i == 7) { // judge total score
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(70);
            }
            else { // printed field - narrow
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(50);
            }
        }
        CarScores.setGridColor(java.awt.Color.blue);
        CarScores.setIntercellSpacing(new Dimension(0,0));
        CarScores.setShowHorizontalLines(true);
        CarScores.setShowVerticalLines(false);
    }
    
    /**
     * formats the ReportTable on the Awards panel for a respectable display.
     */
    private void formatAwardsTable() {
        javax.swing.table.DefaultTableCellRenderer centerRenderer = 
                new javax.swing.table.DefaultTableCellRenderer();
        centerRenderer.setHorizontalAlignment( javax.swing.JLabel.CENTER );
        ReportTable.setShowHorizontalLines(true);
        ReportTable.setGridColor(java.awt.Color.black);
        ReportTable.setShowVerticalLines(false);
        //final javax.swing.table.TableCellRenderer renderer = ReportTable.getDefaultRenderer();
        javax.swing.table.TableColumn column = null;
        for (int i = 0; i < ReportTable.getColumnModel().getColumnCount(); i++) {
            column = ReportTable.getColumnModel().getColumn(i);
            if (i == 0) {// registration # - narrow
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(85);
            }
            else if (i == 1) { // class mnemonic & desc, wide
                column.setPreferredWidth(140);
            }
            else if (i == 3) { // year  - narrow to middling
                column.setMaxWidth(60);
            }
            else if (i == 7) { // judging total score
                column.setCellRenderer(centerRenderer);
                column.setMaxWidth(50);
            }
            else {
                column.setPreferredWidth(90);
            }
        }
    }
    
    /**
     * formats the ClassListTable column widths on the classes admin panel.
     */
    private void formatClassTable() {
        ClassListTable.setShowHorizontalLines(true);
        //ClassListTable.setGridColor(java.awt.Color.blue);
        ClassListTable.setShowVerticalLines(false);
        ClassListTable.getColumnModel().getColumn(0).setMaxWidth(50);
        ClassListTable.getColumnModel().getColumn(1).setPreferredWidth(90);
        ClassListTable.getColumnModel().getColumn(2).setMaxWidth(60);
        ClassListTable.getColumnModel().getColumn(3).setMaxWidth(60);
    }
    
    /**
     * static object used to enumerate the network interfaces for setIpAddress
     * search of active IP addresses.
     */
    static java.util.Enumeration<java.net.NetworkInterface> tok; 

    /**
     * Sets the myIpAddress field in the CarShowUI.  This relies on you having
     * a network setup, otherwise this field will display *NOT CONNECTED*
     * indicating your system is not on any IP network.  This will also make
     * diagnosis of network issues fast with CarShow application.
     */

    private void setIpAddress() {
        String[] rets = null;
        try {
            java.util.Stack<String> ipsStack = new java.util.Stack();
            tok = java.net.NetworkInterface.getNetworkInterfaces();
            while(tok != null && tok.hasMoreElements()) {
                java.net.NetworkInterface n = tok.nextElement();
                if(n.isUp() && !n.isLoopback()) {
                    java.util.Enumeration ienum = n.getInetAddresses();
                    while(ienum.hasMoreElements()) {
                        java.net.InetAddress ia = (java.net.InetAddress)ienum.nextElement();
                        if(ia instanceof java.net.Inet4Address || ia instanceof java.net.Inet6Address)
                            ipsStack.add(ia.getHostAddress());
                    } 
                }
            }
            if(!ipsStack.empty()) {
                if(debug) logger.log(Level.INFO,"setIpAddr: ipsStack found "+ipsStack.size()+" addresses");
                Iterator<String> iter = ipsStack.iterator();
                while(iter.hasNext()) {
                    String s = iter.next();
                    if ((s.matches("[0-9]{2,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?"))) {    
                        if(rets == null) {
                            rets = new String[1];
                            rets[0] = s;
                        }
                        else {
                            String[] nrets = new String[rets.length+1];
                            System.arraycopy(rets, 0, nrets, 0, rets.length);
                            nrets[rets.length] = s;
                            rets = nrets;
                        }
                    }
                }
            }
            if(rets == null || rets.length == 0) myIpAddress = "*NOT CONNECTED*";
            else if (rets.length == 1) myIpAddress = rets[0];
            else {
                myIpAddress = "";
                for(int i = 0; i < rets.length; i++) myIpAddress = myIpAddress+
                    rets[i]+"  ";
            }
        } catch (java.net.SocketException se) {
            // This is what happens when you don't have a network adaptor?
            //Logger.getLogger(CarShowUI.class.getName()).log(Level.INFO, 
            //    "Unknown host exeception on getLocalHost(), probably not connected...", se);
            myIpAddress="*NOT CONNECTED*";
        }
    }
    /**
     * check if the given string is entirely numeric.  Use to validate years
     * of car classes & year of car entry.
     */
    private boolean checkNum(String num) {
        boolean ret = false;
        outer:
        if (!(num == null || num.length() == 0)) {
            for (int i = 0; i < num.length(); i++) {
                if(!Character.isDigit(num.charAt(i)))
                    break outer;
            }
            ret = true;
        }
        return ret;
    }
    
    /**
     * Gets the data for the Administration Panel (carshow name and date)
     * from the DB ShowData table.
     */
    private void getAdminData() {
        String request = "select * from ShowData";
        AdminWait.setEnabled(true);
        AdminWait.setVisible(true);
        if(taskStackStatus(false)) { taskStackStatus(true); }
        sqlGet(AdminPanel, request);
        waitForIt(AdminWait);
    }
    /**
     * This is intended to cause a task-stack resync when it appears we have
     * a new user request.  This should resync the task-stack when it gets
     * out of wry (by a missed DB reply) and cure a lot of the issues with
     * strange results because the stack is corrupted.
     * @param fix whether to fix the broken (true) stack or not
     * @return the status of the stack found (true = broken, false = OK)
     */
    
    private boolean taskStackStatus(boolean fix) {
        boolean ret = false;
        int cnt = ((myJTabbedPane)tabbedPane).getActiveCount();
        if ( cnt > 0) {
            ret = true;
            if(debug) {
                logger.log(Level.INFO,"taskStkStat: non-zero ("+cnt+") aStack detected in tabbedPane");
            }
            if(fix) {
                ((myJTabbedPane)tabbedPane).clearAllActiveComponents();
            }
        }
        return ret;
    }
    /*
     * wait for the specified component to become invisible (disbled) by
     * one of the receiving DB handlers.
     */
    private void waitForIt(Component c) {
        failedWait = false;
        wrapperPanel.setVisible(false);
        waitLit = true;
        if(debug) logger.log(Level.INFO,"wait4it: entering wait on Wait indicator "+c.getName());
        int wait_tmr = waitsCount;
        if(!clientReader.getDone()) {
            while(!clientReader.getDone()) {
                try { Thread.sleep( 300); }
                catch(InterruptedException ie) {
                    logger.log(Level.SEVERE,"wait4it: interrupted sleep exception");
                }
                wait_tmr--;
                if(wait_tmr < 0) {
                    logger.log(Level.SEVERE,"wait4it: clientReader still not done after wait...");
                    break; 
                }
            }
        }
        wait_tmr = waitsCount;
        while(c.isVisible()) {
             try { Thread.sleep( 300); }
             catch(InterruptedException ie) {
                 logger.log(Level.SEVERE,"wait4it: interrupted sleep exception");
             }
             wait_tmr--;
             if(wait_tmr < 0) break;
        }

        if (c.isVisible()) {
            logger.log(Level.SEVERE,"wait4it: wait never ended: "+c.getName());
            c.setVisible(false);  // indeterminate state resultant here...
            failedWait = true;
        }
        else {
            failedWait = false;
        }
        c.setEnabled(false);
        waitLit=false;
        wrapperPanel.setVisible(true);
    }
    /**
     * set the result of an audit action performed by the commandHander
     * Audit actions are to build the tables if missing as well as build
     * the default car judging classes data.  These actions will return a
     * string that may be useful in determining cause of failure at runtime.
     */
    public void setAuditResult(String res) {
        if(debug) logger.log(Level.INFO,"setAuditResult: res="+res);
        setAudRes(res);
    }
    /**
     * Sets the results of the initial database audit during initialization.
     * This return code indicates if any tables were rebuilt and if there
     * were any problems initializing the DB.
     * @param res result string description of results
     * @param code return code, or # of tables updated if >0
     */
    public void setAuditResult(String res, int code) {
        setAudRes(res);
        setAudCode(code);
    }
    private static void setAudRes(String res) {
        auditResult = res;
    }
    private static void setAudCode(int c) {
        auditCode = c;
    }
    
    public String getServer() {
        return SQLServer;
    }

    /*******************************************************************/
    /* Database connection methods and DB Error handlers               */
    /*******************************************************************/

    /**
     * connect to the SQLite/QuickServer host in the network.  The AdminPanel
     * has the ScoringServerName text field containing the name or IP address
     * of the network machine that is hosting the scoring server database.
     * Once connected, the session is kept up between the client and host until
     * the disconnect() method tears down the connection.
     * 
     * There may be systems that do not properly translate the localhost
     * system name into the local IP address (old SuSE Linux systems do
     * this) these systems are dependent on the /etc/hosts table or have
     * broken DNS service connectors.  
     */
    private void connect() {
        if(clientSocket != null) {
            disconnect();
            return;
        }
        String serverName = null;
        if(in_init) serverName = defaultServer;
        else
            serverName = SQLServer;
         if((serverName == null || serverName.equals("")) && !in_init) {
            JOptionPane.showMessageDialog(tabbedPane,
                "No DB host name or IP Address. Please enter" +
                " IP Address (default is localhost)",
                "Error connecting", JOptionPane.ERROR_MESSAGE);
            ScoringServerName.requestFocus();
        }

        InetAddress iaddr = null;
        try {
            if(serverName.equals(defaultServer)) {
              iaddr = InetAddress.getLocalHost();
            }
            else if(serverName.matches("[0-9]{2,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?\\.[0-9]{1,3}?")) {
              iaddr = InetAddress.getByName(serverName);
            }
        } catch (UnknownHostException uhe) {
            logger.log(Level.SEVERE, "connect: Unknown Host exception", uhe.toString());
        }
       try {
            clientSocket = new Socket(iaddr, SQLiteQS.PORT);
        }
        catch (IOException ioe) {
            logger.log(Level.SEVERE, "Client socket to DB server create failed", ioe.toString());
            // clear the active component unconditionally, to restore sanity
            // to the request/reply state machine model in the tabbedPane
            if(tabbedPane != null) { 
                ((myJTabbedPane)tabbedPane).clearActiveComponent
                    (((myJTabbedPane)tabbedPane).getActiveComponent());
                ((myJTabbedPane)tabbedPane).clearWait(); 
            }
        }
        if(tabbedPane != null)
            clientReader = SqlClientReader.capture(tabbedPane,clientSocket);
        else
            clientReader = SqlClientReader.capture(this, clientSocket);
    }

    /**
     * disconnects from the SQL server
     */
    private void disconnect() {
        try {
            clientReader.setDisconnected(true);
            clientSocket.close();
        } catch (Exception e) {
            logger.log(Level.SEVERE,"Error closing client : "+e);
        }
        clientSocket=null;
        out=null;  // printwriter to the socket when data sent in setSQL/getSQL
    }

    /**
     * Handler for null pointer exceptions encountered by the SQLClientReader.
     * We have no way of grabbing the SQLiteCommandHandler or SQLiteQS server
     * NPE exceptions so we will rely on a logger to do that.
     * @param ret 
     */
    void NPEhandler(int ret) {
        if(tabbedPane != null && ((myJTabbedPane)tabbedPane).getActiveComponent() != null) {
            logger.log(Level.INFO,"NPEhandler: ret: "+ret);
            logger.log(Level.INFO,"active pane:"+
                ((myJTabbedPane)tabbedPane).getActiveComponent().getName());
            if(((myJTabbedPane)tabbedPane).getActiveComponent() == RegistrationPanel) {
                if(!FirstName.getText().equals("") && !LastName.getText().equals(""))
                    logger.log(Level.INFO,"Re-execution possible on get/set Entrant");
                else logger.log(Level.INFO,"no re-exec possible, user info already lost...");
            }
            else if (((myJTabbedPane)tabbedPane).getActiveComponent() == JudgeSheetPanel ||
                    ((myJTabbedPane)tabbedPane).getActiveComponent() == JudgeSheetSubPanel) {
                // invalid entrant number specified
                logger.log(Level.INFO,"NPEhandler: detected form was JudgingSheets");
                if(JS_EntrantNumber.getText().equals("")) {
                    clearJudgingSheet((byte)7);
                }
            }
            else if (((myJTabbedPane)tabbedPane).getActiveComponent() != null) {
                logger.log(Level.INFO,"NPEhandler detected form was "+
                    ((myJTabbedPane)tabbedPane).getActiveComponent().getName());
            }
        }
        else { // this can only hit in init and then only if ClientHandler has an NPE
            if(!in_init | debug) logger.log(Level.WARNING, "NPEhandler: null "+
                "tabbedPane or activeComponent null");
            // tabbedPane == null || getActiveComponent == null
            // initialization phase of SQLiteQS server or DB init 
        }
        // try and correct stack problems caused by an NPE
        // but only the oldest component if more than one
        if(((myJTabbedPane)tabbedPane).getActiveCount() > 1) {
            java.awt.Component c = ((myJTabbedPane)tabbedPane).getTopComponent();
            ((myJTabbedPane)tabbedPane).clearActiveComponent(c);
        }
        else  {
            ((myJTabbedPane)tabbedPane).clearActiveComponent(
                ((myJTabbedPane)tabbedPane).getActiveComponent());
        }
    }
    
    /**
     * This is a recovery & error return path from the SqlClientReader.  It
     * tries to recover from bad things that happen when the client socket
     * gets trashed during an SQL query/update request.  The logic of how
     * to recover isn't very robust yet so this will need tweaking as DB
     * comm problems trigger this and those are not predictable.
     * @param why 
     */
    void clientSocketError(int why) {
        if(why < 0) {
            switch (why) {
                case -1:
                    logger.log(Level.SEVERE,"clientSocketError: socket not connected in client");
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                case -2:
                    logger.log(Level.SEVERE,"clientSocketError: socket closed in/for client");
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                case -3:
                    logger.log(Level.SEVERE,"clientSocketError: client reader "+
                        "null panel, with result set/return code");
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                case -4:
                    logger.log(Level.SEVERE,"clientSocketError: client reader "+
                        "unrecognized panel, with result set/return code, active panel:"+
                        ((myJTabbedPane)tabbedPane).getActiveComponent().getName());
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                case -5:
                    logger.log(Level.SEVERE,"clientSocketError: client reader "+
                        "null panel, with result null result set/code");
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                case -6:
                    //logger.log(Level.SEVERE,"clientSocketError: client reader "+
                    //    "unrecognized non-null panel, with result null result set/code");
                    int cnt = ((myJTabbedPane)tabbedPane).getActiveCount();
                    if(cnt > 0) {
                        if(cnt > 1) {
                            logger.log(Level.SEVERE,"clientSocketError: client reader "+
                        "unrecognized non-null panel, with result null result set/code"+
                        " current aStack size: "+cnt);
                        }
                        else {
                            logger.log(Level.SEVERE,"clientSocketError: client"+ 
                                "reader unrecognized non-null panel, with "+
                                "result null result set/code, active panel:"+
                                ((myJTabbedPane)tabbedPane).getActiveComponent().getName());
                        }
                    }
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
                default:
                    logger.log(Level.INFO,"clientSocketError: unknown reason:"+why);
                    ((myJTabbedPane)tabbedPane).clearWait();
                    break;
            }
        }
        // We may need more drastic methods here to recover but we don't seem
        // to be taking this path frequently so sync problems may not be
        // alleviated by doing a wipe of the SQL waiting component stack here
        if(((myJTabbedPane)tabbedPane).getActiveCount() > 1) {
            java.awt.Component c = ((myJTabbedPane)tabbedPane).getTopComponent();
            ((myJTabbedPane)tabbedPane).clearActiveComponent(c);
        }
        else  {
            ((myJTabbedPane)tabbedPane).clearActiveComponent(
                ((myJTabbedPane)tabbedPane).getActiveComponent());
        }
    }
    
    /**
     * gets the initialization flag which indicates the UI is in the constructor
     * initialization phase.  This is used by the SqlClientReader class to
     * glean the severity of zero-length return values sent by the 
     * SQLiteCommandHandler (local or remote) during DB initialization.  Of
     * course, this would only be applicable on the localhost (a remote won't
     * be able to initialize the DB) so it may be superceded by a different
     * logical tautology about system state later.
     * @return initialization state of CarShowUI
     */
    boolean getInitState() {
        return in_init;
    }
    
    /**
     * renders a thick right-hand-side border to table cells
     */
    private static class ThickRightBorderCellRenderer
          extends javax.swing.table.DefaultTableCellRenderer {

        @Override
        public javax.swing.border.Border getBorder() {
            return javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 2, Color.BLACK);
            //return javax.swing.BorderFactory.createLineBorder(Color.BLACK, 2);
        }
    }
    /**
     * renders a medium weight bottom border to table cells
     */
    private static class AutoResizeCellRenderer
           extends javax.swing.table.DefaultTableCellRenderer {
        public javax.swing.border.Border getBorder() {
            //return javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK);
            return javax.swing.BorderFactory.createLineBorder(Color.BLACK, 1);
        }
    }
    
    /**
     * Class to present a list of entrants when a search returns multiple
     * results. See the setMultiEntrant() method for usage.
     */
    private class EntrantSearchResults extends javax.swing.JFrame implements ActionListener {
        javax.swing.JTable resultTable;
            
        private javax.swing.JButton selButton;    
        
        public EntrantSearchResults() {
            super();
            setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
            setTitle("Entry Search Results");
            getContentPane().setLayout(
            new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS));
            getContentPane().setLayout(
                new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));

            EntrantSelectTableModel estm = new EntrantSelectTableModel();
            resultTable = new javax.swing.JTable(estm);
            resultTable.setPreferredScrollableViewportSize(new Dimension(504, 100));
            resultTable.setFillsViewportHeight(true);
            resultTable.getSelectionModel().addListSelectionListener(new RowListener());
            resultTable.setIntercellSpacing(new Dimension(0,0));
            javax.swing.table.TableColumn column = null;
            for (int i = 0; i < resultTable.getColumnModel().getColumnCount(); i++) {
                column = resultTable.getColumnModel().getColumn(i);
                column.setCellRenderer(new ThickRightBorderCellRenderer());
                if (i == 0) // registration # narrow always
                    column.setMaxWidth(30);
                else if (i == 1) { // car class field narrow
                    column.setMaxWidth(30);
                }
                else if (i == 2) { // state mnemonic field
                    column.setMaxWidth(60);
                }
                else if (i == 3) { // state mnemonic field
                    column.setPreferredWidth(50);
                }
                else if (i == 5) { // state mnemonic field
                    column.setMaxWidth(105);
                }
                else if (i == 6) { // state mnemonic field
                    column.setMaxWidth(30);
                }
                else if (i == 7) { // year field
                    column.setMaxWidth(40);
                }
                else if (i == 8 || i == 9) { // year field
                    column.setMaxWidth(70);
                }
                else {
                    column.setPreferredWidth(60);
                }
            }
            selButton = new javax.swing.JButton("Select");
            selButton.addActionListener(this);
            this.add(resultTable);
            this.add(selButton);
            pack();
        }
        
        public void actionPerformed(ActionEvent event) {
            String command = event.getActionCommand();
            if(command.equals("Select")) {
                if(debug) logger.log(Level.INFO,"Select handler actPerf: entry");
                // the selected button has been pressed, gather the selected
                // item from the list and indicate what which entrant to
                // populate the form with...
                int rnum = resultTable.getSelectedRow();
                if(debug) logger.log(Level.INFO,"SelectActPerf: rownum:"+rnum);
                if(rnum >= 0) {
                    String[] rets = ((EntrantSelectTableModel)resultTable.getModel()).getRawAt(rnum);
                    if(debug) logger.log(Level.INFO,"SelectActPerf: rets length:"+rets.length);
                    StringBuffer sb = new StringBuffer();
                    for(int z = 0; z < rets.length-1; z++)
                        sb.append(rets[z]+",");
                    sb.append(rets[rets.length-1]);
                    this.setEnabled(false);
                    this.setVisible(false);
                    this.setAlwaysOnTop(false);
                    this.dispose();
                    setEntrant(sb.toString());
                }
            }
        }
        
        /**
         * listener for row selection in the JTable
         */
        private class RowListener implements ListSelectionListener {
            public void valueChanged(ListSelectionEvent event) {
                if (event.getValueIsAdjusting()) {
                    return;
                }
                if(debug) logger.log(Level.INFO,"RowListener: ROW SELECTION EVENT. ");
            }
        }
        /**
         * Sets the table height using the number of rows in the table.
         */
        private final static int stdVertOffset = 60;
        public void scaleTable() {
            int rowcnt = resultTable.getRowCount();
            int rowsize = resultTable.getRowHeight();
            int tblsize = rowcnt * rowsize;
            int btnsize = selButton.getHeight();
            int newheight = tblsize + btnsize + stdVertOffset;
            this.setSize(700,newheight);
        }
    }

    /**
     * Table model of the selection panel displayed when multiple entrants are
     * returned on Entrant Search.  The model keeps a visible copy of the
     * entrant data and a raw copy of the entrant data to be given back to
     * setEntrant() when an entrant has been selected from the list.
     */
    private class EntrantSelectTableModel extends javax.swing.table.AbstractTableModel {
        
        private String[] columnNames = {"Registration", "Class",
                                        "First Name", "Last Name", "Address",
                                        "City", "State", "Year","Make", "Model",
                                        };
        private String[][] data = {};
        
        private String[][] rawdata = {};

            
        public EntrantSelectTableModel() {

        }
        
        public void removeRow(int i) {
            if(data.length > 0 && i < data.length) {
                for(int j = 0; j < 10; j++)
                data[i][j] = null;
            }
            data[i] = null;
            rawdata[i] = null;
        }
        
        public void insertRow(int i, String[] args) {
            if(i < 0) return;
            if(i >= data.length)
                data[i] = new String[10];
            data[i][0] = args[0];
            data[i][1] = args[3];
            data[i][2] = args[1];
            data[i][3] = args[2];
            data[i][4] = args[4];
            data[i][5] = args[5];
            data[i][6] = args[6];
            data[i][7] = args[12];
            data[i][8] = args[10];
            data[i][9] = args[11];
            if(rawdata.length > i && rawdata[i] == null) rawdata[i] = new String[args.length];
            else {
                String[][] nraw = new String[rawdata.length+1][args.length];
                System.arraycopy(rawdata,0,nraw,0,rawdata.length);
                rawdata=nraw;
            }
            for(int k = 0; k < args.length; k++)
                rawdata[i][k] = args[k];
        }
        
        public void addRow(String[] args) {
            int i = data.length;
            if(i == 0) data = new String[1][10];
            else {
                int d = data.length + 1;
                String[][] ndata = new String[d][10];
                for (int j=0; j < data.length; j++) {
                    for ( int k = 0; k < 10; k++ )
                    {
                        ndata[j][k] = data[j][k];
                    }
                }
                data = ndata;
            }
            data[i][0] = args[0];
            data[i][1] = args[3];
            data[i][2] = args[1];
            data[i][3] = args[2];
            data[i][4] = args[4];
            data[i][5] = args[5];
            data[i][6] = args[6];
            data[i][7] = args[12];
            data[i][8] = args[10];
            data[i][9] = args[11];
            if(rawdata.length == 0) rawdata = new String[1][args.length];
            else {
                String[][] nraw = new String[rawdata.length+1][args.length];
                System.arraycopy(rawdata,0,nraw,0,rawdata.length);
                rawdata = nraw;
            }
            System.arraycopy(args, 0, rawdata[i], 0, args.length);
        }

        public int getRowCount() {
            return data.length;
        }

        public int getColumnCount() {
            return columnNames.length;
        }

        public String getValueAt(int i, int j) {
            return data[i][j];
        }
        
        public void setValueAt(String aValue, int i, int j) {
            data[i][j] = aValue;
        }
        public String[] getRawAt(int i) {
            return rawdata[i];
        }
    }

    /**
     * focus traversal policy for the Registration Panel.
     * Needed due to deprecation of the calls that would chain
     * these in the old standard javax.swing libraries.  This implements the
     * customer's order of field tab selections on the registration panel.
     */
    private static class regLayoutFocusTraversalPolicy extends FocusTraversalPolicy {
        java.util.Vector<Component> order;
 
        public regLayoutFocusTraversalPolicy(java.util.Vector<Component> order) {
            this.order = new java.util.Vector<Component>(order.size());
            this.order.addAll(order);
        }
        public Component getComponentAfter(Container focusCycleRoot,
                                           Component aComponent)
        {
            int idx = (order.indexOf(aComponent) + 1) % order.size();
            return order.get(idx);
        }
 
        public Component getComponentBefore(Container focusCycleRoot,
                                            Component aComponent)
        {
            int idx = order.indexOf(aComponent) - 1;
            if (idx < 0) {
                idx = order.size() - 1;
            }
            return order.get(idx);
        }
 
        public Component getDefaultComponent(Container focusCycleRoot) {
            return order.get(0);
        }
 
        public Component getLastComponent(Container focusCycleRoot) {
            return order.lastElement();
        }
 
        public Component getFirstComponent(Container focusCycleRoot) {
            return order.get(0);
        }
    }

    /**
     * Handler for post processing key input events which implements the
     * auto completion capability of the registration panel club entry field.
     * This overrides the normal key handling for the entire application so
     * if you wish to have the auto complete work on a different jTextField
     * or some other object in the GUI here is where you'd insert your
     * handling.
     */
    private class typedKeyListener implements KeyEventPostProcessor {

        @Override
        public boolean postProcessKeyEvent(KeyEvent e) {
            if(e.getID() != 0) {
                //System.err.println("postProcKeyEvent: id is:"+e);
                if(e.getID() == KeyEvent.KEY_TYPED) {
                    Object c = e.getSource();
                    if(c instanceof javax.swing.JComboBox) {
                       if(debug) System.err.println("source is a jtext field");
                       if(debug) System.err.println("name is: "+((javax.swing.JComboBox)c).getName()); 
                    }
                    if(c instanceof javax.swing.JTextField) {
                        if(debug) System.err.println("source is a jtext field");
                        if(debug) System.err.println("name is: "+((javax.swing.JTextField)c).getName());
                        Component pc = ((javax.swing.JTextField)c).getParent();
                        if(pc.getName().equals("EntrantClub")) {
                            if(debug) System.err.println("parent was entrant club");
                            char inChar = e.getKeyChar();
                            String curStr = ((javax.swing.JTextField)c).getText();
                            if(curStr.startsWith(" ")) {
                                curStr = curStr.replaceFirst("[\\s]+", "");
                            }
                            // sift activeClubs to find matching preamble chars
                            int clubcnt = EntrantClub.getItemCount();
                            String[] clublist = new String[clubcnt];
                            for(int n = 0; n < clubcnt; n++) {
                                clublist[n] = ((String)EntrantClub.getItemAt(n)).trim().toLowerCase();
                            }
                            if(curStr.trim().length() > 0) { // new club name isn't spaces
                                String prefix = curStr.toLowerCase();
                                int pos = prefix.length();
                                for(int n = 0; n < clubcnt; n++) {
                                    if(clublist[n].startsWith(prefix)) {
                                        ((javax.swing.JTextField)c).setText((String)EntrantClub.getItemAt(n));
                                        ((javax.swing.JTextField)c).setCaretPosition(pos);
                                        ((javax.swing.JTextField)c).setSelectionStart(pos);
                                        ((javax.swing.JTextField)c).setSelectionEnd(clublist[n].length());
                                        break;
                                    }
                                }
                                if(debug) System.err.println("last char of string is "+inChar);
                            }
                            else {
                                if(debug) System.err.println("curChars last char isnt a Char, curChars: "+curStr);
                                if(debug) System.err.println("inChar: "+inChar);
                            }
                        }
                    }
                }
            }
            return false;
        }
    }
}
